Send SMS using Twilio Super SIM API

Hi everyone, i am struggling to configure a new Twilio Super sim which i would like to use in a gps tracker.
Twilio Super sims do not have a publicly addressable phone number. The only way to reach it via SMS is by using the SMS Commands API

curl -X POST https://supersim.twilio.com/v1/SmsCommands \
  --data-urlencode 'Sim=<YOUR_SIM_NAME_OR_SID>' \
  --data-urlencode 'Payload={"command":"wake","time":"2021-04-19-15-03-49"}' \
  -u <YOUR_ACCOUNT_SID>:<YOUR_AUTH_TOKEN>​

Since i do not have a static IP i need to be able to pass a dynamic value to the payload… To configure the gps tracker with my new IP i need to send the following: G123456 IP PORT → G123456 xxx.xxx.xxx.xxx 5093.

I also need to use this in an automation to automatically update my tracker when my public ip changes.

Using the following generates a [sim] is an invalid option for [rest_command] error message, which is normal.
Adding the sim parameter in the Headers generates an authorization error (401)

  twilio_send_sms:
    url: "https://supersim.twilio.com/v1/SmsCommands"
    method: POST
    sim: !secret twilio_sim_sid
    headers:
      authorization: !secret twilio_auth
      accept: 'data-urlencode'
    payload: 'adminip123456 {{ states("sensor.myip") }} 5093'
    content_type: 'data-urlencode'

I have considered using shell commands but I lack the skills to make this work.
Any ideas will be welcome.

Thanks!

1 Like

Hello @desosav . I think you should try to your rest command to put username and password in order to avoid Unauthorized logins.

 twilio_send_sms:
    url: "https://supersim.twilio.com/v1/SmsCommands"
    method: POST
    username: !secret twillo_account_sid
    password: !secret twillo_tkn
    sim: !secret twilio_sim_sid
    headers:
      accept: 'data-urlencode'
    payload: 'adminip123456 {{ states.sensor.myip }} 5093'
    content_type: 'data-urlencode'

Hi there thanks for your input. This is generating the following: [sim] is an invalid option for [rest_command]

For anyone interested i was able to make this work by using the shell command integration and running the following:

'curl "https://supersim.twilio.com/v1/SmsCommands" -X POST --data-urlencode "Sim=<YOUR_SIM_NAME_OR_SID>" --data-urlencode "Payload=adminip123456 {{ states("sensor.myip") }} 5093" -u "<YOUR_ACCOUNT_SID>:<YOUR_AUTH_TOKEN"'

Obviously you can add the curl command in secrets.yaml since it contains sensitive information.

Great article and help.
Just wanted to mention that you can achieve same type of functionality with the twilio-cli. It is a bit less wordy when trying to perform the sms commands

example :
twilio api:supersim:v1:sms-commands:create --sim <sim_id> --payload ‘’