Template to use HTTP SMS API with Plivo

alexthefifth4 years ago

Maybe could be added to https://www.traccar.org/http-sms-api/

    <entry key='notificator.types'>web,mail,sms</entry>
    <entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
    <entry key='sms.http.url'>https://api.plivo.com/v1/Account/AUTHID/Message/</entry>
    <entry key='sms.http.user'>AUTHID</entry>
    <entry key='sms.http.password'>AUTHTOKEN</entry>
    <entry key='sms.http.template'>{"src": "SOURCEPHONE", "dst": "{phone}", "text": "{message}"}</entry>

Make sure to replace these variables based on your Plivo account:
AUTHID, AUTHTOKEN, SOURCEPHONE

Plivo API reference: https://www.plivo.com/docs/sms/api/message#send-a-message

I think Nexmo and Messagebird have very similar APIs:

https://developer.nexmo.com/concepts/guides/authentication
https://developer.nexmo.com/messaging/sms/code-snippets/send-an-sms

https://developers.messagebird.com/api#authentication
https://developers.messagebird.com/api/sms-messaging#send-outbound-sms

Nexmo is pretty cool because you can initiate phone calls using the API and then have it read out the message using "text to speech":
https://developer.nexmo.com/voice/voice-api/code-snippets/make-an-outbound-call-with-ncco

curl -X POST https://api.nexmo.com/v1/calls\
  -H "Authorization: Bearer "$JWT\
  -H "Content-Type: application/json"\
  -d '{"to":[{"type": "phone","number": "'$TO_NUMBER'"}],
      "from": {"type": "phone","number": "'$NEXMO_NUMBER'"},
      "ncco": [
        {
          "action": "talk",
          "text": "This is a text to speech call from Nexmo"
        }
      ]}'

Unfortunately the Nexmo voice API requires the use of JWT for authentication. Which have an expiry date. So I haven't figured out how to integrate with traccar yet:
https://developer.nexmo.com/concepts/guides/authentication#json-web-tokens-jwt

The UNIX timestamp at UTC + 0 indicating the moment the JWT is no longer valid. A minimum value of 30 seconds from the time the JWT is generated. A maximum value of 24 hours from the time the JWT is generated. A default value of 15 minutes from the time the JWT is generated.