This example shows how you can manage your Tesla with SMS using webMethods.io Integration. The functionality covers following SMS requests for Tesla:
- Get State
- Get Location
- Unlock Doors
- Lock Doors
Overview
The logical flow of SMS to manage Tesla using webMethods.io is depicted in a below diagram.
The flow consists of:
- User sends SMS message to Twilio phone number.
- Twilio performs http post request to webMethods.io workflow.
- webMethods.io workflow uses Tesla connector to send appropriate request to Tesla car.
- webMethods.io workflow uses connector for Tesla to recieve appropriate response from step 3.
- webMethods.io workflow uses Twilio connector to send appropriate response to Twilio.
- Twilio sends SMS message to Mobile Phone from step 1.
Document References:
webMethods.io Connector - Tesla
webMethods.io Connector - Twilio
Prerequisites
- Twilio account with at least one phone number to receive and send SMS. Account SID and Auth Token from Twilio Account Dashboard.
- Actual Tesla and your credential for Tesla account.
- webMethods.io Integration account.
Setup
-
Log in to webMethods.io Integration.
Once you log in, you will be redirected to the dashboard. Here, you will see a Default project, and the + New Project option to create a new project. Projects are like folders that save your workflows within them and help you categorize your workflows. Read more about Projects.
Click on the Default project to create a new workflow within it.
-
Create a blank workflow.
Click the + New Workflow button. This will redirect you to a new window where you can choose the option to 'Create Blank Workflow'
-
Rename the workflow.
Click on the Edit icon given beside the workflow name, at the top-left corner of the canvas. A new window will appear, where you can add or modify workflow details such as name, tags, and description. Once you have entered these details, click on Done. This will take you back to the canvas.
-
Add Webhook to the workflow.
Trigger is the starting point of a workflow. Therefore, the Start icon houses all the settings related to triggers. Hover on the Start icon, and click the Settings icon to add and configure a trigger.
a. Select Webhook for the trigger.
![webhook-trigger](upload://dkY1sUpqZh2i1E2ctnuBaDLY7dj.png)
b. Copy Webhook URL to a notepad. This URL will be needed to be configured in Twilio. Click on Next button.
![webhook-trigger](upload://s63O2xSs7uSvNsA5NV91KOvPmZ8.png)
c. Add following json snippet to the body of Webhook. This makes it easier to map the input data in next set of actions. Note: the json snippet is what Twilio HTTP Post will send when a SMS message is received by the Twilio phone number.
![webhook-trigger](upload://1NxkHvYHUnBtB0UUg2mFCySHHo9.png)
d. Accept defaults in next 2 windows.
![webhook-trigger](upload://r3ElDmNA3MejMLwbNZh4xacqcY4.png)
![webhook-trigger](upload://zXePhwSlgyZqVhDIhhvbz0s9TJQ.png)
-
Add Switch selection control to the workflow.
![switch-selection-1](upload://xqQtkT00hC2R4PVHS1zchOoIiIH.png)
The Switch selection control will be connected from the Start. This switch will be configured to handle 2 conditions per the next step.
-
For Condition 1, add Twilio connector to the workflow. Make sure to connect 'Switch' and 'End'.
![wm-io-twilio-response-1](upload://nU825Yv8JXWzsWqraCNMD6b8l8c.png)
a. Configure Switch 'case 1' per below:
**Condition will check for SMS message *not* containing either of the following words: 'State, Location, Lock, Unlock'.** i. Click on 'case 1' flow that is connecting Switch and Twilio connector. Select Cog wheel to configure the settings for the 'case 1'.
![wm-io-switch-case-1](upload://6D8rOJj9jh6OAb68z5eOZmKinT2.png)
ii. Add transform to convert incoming SMS body to be upper case. This will be used for condition matching. Configure per below.
![wm-io-switch-case-2](upload://ikmUXylLVib0a0R3IA0nvNAnDHs.png)
![wm-io-switch-case-3](upload://bruVpApjSmyCPJY8w81rFvCjuAe.png)
Click button 'Done'.
iii. Add Condition to check for incoming message. Use the transform value from previous step. The conditions are setup to not match string value 'state', 'location', 'lock', 'unlock'.
![wm-io-switch-case-4](upload://oFnfSZSaIKKmTN1ZAcE8G5rqabg.png)
b. Configure Twilio connector.
Configure Twilio connector to send SMS message to the requester when conditions are setup to not match string value 'state', 'location', 'lock', 'unlock'. i. Hover over the Twilio connector and select Cog wheel to configure the settings.
![wm-io-twilio-response-2](upload://5G95FfDJpUAnYbhDvgJd9Kprv11.png)
ii. Configure per below. Set the value per below and click on + button.
![wm-io-twilio-response-3](upload://oUdhCiCVYIOhhRCvQ6agayG00c4.png)
Set the Twilio Account SID and Auth Token value for your Twilio Account per below
![wm-io-twilio-response-4](upload://mWG9TNFvJun3MUGt8FTbLIdxsQZ.png)
Map Incomming data to Twilio SMS per below. Note the field mappings: *$request - webhook/body/From* mapped to *To Number*. *$request - webhook/body/To* mapped to *From Number*. Set the value of Twilio SMS Message to 'Please text one of only following: state, location, lock, unlock'
![wm-io-twilio-response-5](upload://xmp4pkiPF7Q64UuylfxHd1R5K0d.png)
-
For Condition 2, Add Tesla Connector which will be used to wake up your Tesla car.
a. Connect Switch to Tesla Connector per below. This connector will be used to wake up the Tesla car.
![wm-io-tesla-1](upload://zDPB9vuHXLxw6OgchD1mkaya32b.png)
b. Click on 'case 2' flow that is connecting Switch and Tesla connector. Select Cog wheel to configure the settings for the 'case 2'. Configure the conditions per below.
Note: Upper Case transform of incoming Body. Configure 4 conditions for STATE, LOCATION, LOCK, UNLOCK.
![wm-io-switch-2](upload://2Rxj1SLCv7Vj3Hab368S6Ms6Ac2.png)
c. Configure Tesla connector to wake up the car. You will need credential for your tesla account.
i. Hover over the Tesla connector and select Cog wheel to configure the settings.
![wm-io-tesla-2](upload://vrkFGmoUn3zQ2WDdxA0NRpuCs0w.png)
ii. Select Action 'Wake Up Car', and click on + button per below and select 'Default Authorization'.
![wm-io-tesla-3](upload://8WruIO9KGohSC0FZlLx0WtJW7nx.png)
iii. Enter your credentials for Tesla account.
![wm-io-tesla-4](upload://am4BJYow3fe5NwhySSBXer6x4pN.png)
iv. Provide account name; can be any name as this will be used later in this setup.
![wm-io-tesla-5](upload://6eMDUoXqNhntXNNv5w6I8iD0eLa.png)
v. Select your Vehicle Id. One or more vehicles will be listed from your Tesla account. Accept default in next set of screen(s).
-
Add Switch selection control. Connect Tesla 'Wake My Car' to the newly added Switch control.
-
Add Tesla connector. Connect Switch selection control to newly added Tesla connector. This Tesla connector will be configured to get the state of your Tesla car and repond the state back as a SMS to the mobile phone.
i. Configure 'Case 1' to check for incoming sms body message to match 'state'.
![wm-io-switch-case-5](upload://4qQzUDE8ve14j9xte8dyIJNvCCe.png)
ii. Configure Tesla connector to use 'Get Vehicl State' of your Tesla car per below set of screens. You do not need to add new authorization for your Tesla connector as authorization has already been registered and can be reused. Also, use the same vehicle id as used in previous Tesla configuration because the state of same vehicle that was woken up in the previous Tesla connector. Make sure to 'Test' the connector so that response is retrieved and can used on next set of actions.
![wm-io-tesla-7](upload://4Hu6ucUELW2y3NcW3i0cfKipFj4.png)
-
Add and configure Twilio connector to send state of your Tesla car as SMS back to the mobile phone number. Connect 'Get Vehicle State' Tesla connector to newly added Twilio connector; connect Twilio connector to End. See screens below for configuration.
![wm-io-tesla-get-state-flow](upload://soCqcIUZr3mtQWLuiFqKPDqsp53.png)
![wm-io-twilio-response-6](upload://gq2xXrdDBtle2lN9SOK92zr6bDI.png)
Map Incomming data to Twilio SMS per below. Note the field mappings:
*$request - webhook/body/From* mapped to *To Number*. *$request - webhook/body/To* mapped to *From Number*. Set the value of Twilio SMS Message to include following Vehicle: $a4 - Get Vehicle State/vehicle_name Vehicle: $a4 - Get Vehicle State/locked Vehicle: $a4 - Get Vehicle State/is)user_present
![wm-io-twilio-response-7](upload://dxZyyc3UG8Rh5BkiVTjRuZQofdl.png)
-
Add and configure Twilio connector to SMS location of your Tesla car to the mobile phone number.
i. Add Tesla connector. Connect Switch selection control to newly added Tesla connector. This Tesla connector will be configured to get the location of your Tesla car and repond the location back as a SMS to the mobile phone.
Add Twilio connector. Connect Tesla connector to newly added Twilio connector. Connect Twilio connector to End.
ii. Configure 'Case 2' to check for incoming sms body message to match 'LOCATION'.
iii. Configure Tesla connector to 'Get Vehicle State and Location'.
iv. Configure Twilio connector to SMS location of Tesla car to the mobile phone number.
-
Add and configure Twilio connector to lock your Tesla car.
i. Add Tesla connector. Connect Switch selection control to newly added Tesla connector. This Tesla connector will be configured to Lock Doors of your Tesla car.
ii. Add Twilio connector. Connect Tesla connector to newly added Twilio connector. Connect Twilio connector to End.
iii. Configure 'Case 3' to check for incoming sms body message to match 'LOCK'.
iv. Configure Tesla connector to 'Lock Doors'.
![wm-io-tesla-10](upload://mo8y2iscT14QaLMUgUbHgZQzex0.png)
v. Configure Twilio connector to SMS result of Tesla Connector 'Lock Doors' action to the mobile phone number.
![wm-io-twilio-response-8](upload://cWS9c1v5dRGVB9eI1T06Q2pqbP4.png)
Create a Transform that 'Stringify' result of 'Lock Doors' action as the result is a boolean value.
![wm-io-tesla-11](upload://18vio9FCjqyk0GvhyMZiwxNukfd.png)
Map following values for Twilio. *$request - webhook/body/From* mapped to *To Number*. *$request - webhook/body/To* mapped to *From Number*. Transform for strigified result to Message
![wm-io-twilio-response-9](upload://lm2JNlUD9CNlsXZTpXzpEZFHf0b.png)
-
Add and configure Twilio connector to unlock your Tesla car.
i. Add Tesla connector. Connect Switch selection control to newly added Tesla connector. This Tesla connector will be configured to Unock Doors of your Tesla car.
ii. Add Twilio connector. Connect Tesla connector to newly added Twilio connector. Connect Twilio connector to End.
iii. Configure 'Case 4' to check for incoming sms body message to match 'UNLOCK'.
iv. Configure Tesla connector to 'Unlock Doors'.
![wm-io-tesla-12](upload://4OAyesLDb49RDiHT5uIQOKtQp6R.png)
v. Configure Twilio connector to SMS result of Tesla Connector 'Unlock Doors' action to the mobile phone number.
![wm-io-twilio-response-10](upload://tTKLiuoxIuonS8i8miaqrTrfkXM.png)
Create a Transform that 'Stringify' result of 'Unlock Doors' action as the result is a boolean value.
![wm-io-twilio-response-11](upload://bFMJEACbBiem7UiMPoCxpEKeLjl.png)
Map following values for Twilio. *$request - webhook/body/From* mapped to *To Number*. *$request - webhook/body/To* mapped to *From Number*. Transform for strigified result to Message
![wm-io-twilio-response-12](upload://1WPidQp2XEzhnoAontkaVyWWlND.png)
-
Configure Twilio phone number to send http post request to the webhook of the workflow.
a. Login in to your Twilio Account: https://www.twilio.com/login
b. Navigate to Active Numbers: https://www.twilio.com/console/phone-numbers/incoming
c. Click on one of your phone number that you want to use to post SMS messages to webMethods.io Integration Flow
![wm-io-twilio-config-1](upload://7JcvcCkhIgYHMoG1L4bxlbPxxiT.png)
d. Navigate to Messaging section of the Twilio phone number and add the URL of webhook of the workflow.
![wm-io-twilio-config-2](upload://jZyXUtjLS8o5WUX5eOXWlIBEHhp.png)
-
You can test by sending following SMS to your Twilio phone number: State, Location, Lock and Lock.
![sms-my-tesla-test-1](upload://AqJGUFpmChZLWp5txO3T3irlt9y.jpeg)
Additional
-
Use authentication token to secure your webhook: https://docs.webmethods.io/integration/developer_guide/webhook/#ta-webhook_authentication.
-
Add delay timer after Tesla Connector for 'Wake Up CAr' to account for delay in your Tesla waking up. Delay timer is available under Developer Tools.
-
webMethods.io Integration Documentation: https://docs.webmethods.io/integration/starthere/home/#gsc.tab=0.
-
You can configure Location SMS to send Google Maps Marker by adding following in Twilio Message include latitude and longitude variables: Vehicle Location: https://www.google.com/maps/search/?api=1&query=*latitude*,*longitude*.
-
Completed solution sms-my-tesla.zip can be imported per instructions.