[Solved] Use twillio API to send SMS messages

how-to

#1

Hi,

we’ve been asked on how to connect to twillio platform, in particular to send SMS from IntuiFace Experiences.

We made some test with twillio API, and good news ! It works well with IntuiFace :tada:.

First thing to look at is their documentation. It’s pretty clear and straight forward.

You can copy the curl command they provide in API Explorer :

curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json' \ --data-urlencode 'To=+TO_NUMBER' \ --data-urlencode 'From=+FROM_NUMBER' \ --data-urlencode 'Body=YOUR_MESSAGE' \  -u YOUR_ACCOUNT_SID: YOUR AUTH TOKEN

You’ll need to replace following parameters with you own information :

Once everything is set-up you’ll just have to send the request and check you phone :calling:

Alban


#2

You must be a mind reader Alban because this is what i was testing :D.

Louie


#3

Note for our french users, we also successfully sent SMS using SMSenvoi.

You can check their documentation here and paste the following request in API Explorer

http://www.smsenvoi.com/getapi/sendsms/?email=EMAIL_ACCOUNT&apikey=API_KEY&message[type]=sms&message[subtype]=PREMIUM&message[senderlabel]=Expediteur&message[recipients]=PHONE_NUMBER&message[content]=MESSAGE

As for Twillio, you’ll need to replace all uppercase fields with your own information.

Seb


#4

I actually have this as a custom asset in my experiences. Can I sell this in the marketplace?

Richard


#5

Hi @richardkollen,

You can publish an experience on the Marketplace that would illustrate the custom asset you created, for sure!


#6

This is pretty amazing… I am trying to add this to an experience that I have debuting this weekend. Would anyone of you guys be able to help me get this running? I’ve been playing around with it, and I have not been able to get the authentication to work.

Any help would be appreciated!

Thanks

Shawn


#7

Hi Shaun,

I think there was a typo in the first message of this thread. The correct curl command would be

curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json' \ --data-urlencode 'To=+TO_NUMBER' \ --data-urlencode 'From=+FROM_NUMBER' \ --data-urlencode 'Body=YOUR_MESSAGE' \ -u YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN

It seems that another option is to use api keys as documented here: https://www.twilio.com/docs/api/rest/keys

Hope this helps

Seb


#8

Thanks for the reply Seb. I’ve been playing around with it and figured out that syntax… I still can’t get it to stop giving me a 401 error.

This is the command that I am pasting into the Request URL field of the API Explorer (I don’t mind that you see my tokens… it’s just a test twilio at this point)

[EDIT: PRIVATE INFO]

those are the correct live creds. Any idea what might be up?


#9

Let’s avoid sharing your private credentials in a public comment :slight_smile: I edited your message.
I’ll try to do some tests on that topic and come back to you before the end of the day.


#10

I sent the “answer” to Shawn in pm since it contains his credentials, but for others, here is the info:

I just started from the curl I provided in the thread then replaced the parameters with yours.
I used https://www.blitter.se/utils/basic-authentication-header-generator/1 to generate the bearer token for the basic auth field.


#11

Does anyone know if this works with sending images via SMS? Considering setting it up for a selfie station program to send users their photos.


#12

Hi @scott,

I recommend you to check:

The combination of these 2 articles should give you the info to test it on your side.

Seb