1
votes

I have a Twilio SMS number configured to send a request to a WebServer via a Webhook URL. What I am trying to understand is can I pass the 'from' phone number and 'SMS body' as parameters in the Webhook URL?

For example:

https://myserver/v1/sms?phoneNo='FROM'&message='MSG'

I understand I can extract this information from the Body on the server but this would require additional coding, testing, deployment etc... on the web server.

Thanks.

1

1 Answers

2
votes
  • Keep the URL as https://myserver/v1/sms (Twilio will add the parameters for you when it makes the request)

  • To the right of the webhook url field, change in the drop-down from HTTP POST to HTTP GET

enter image description here

  • Save

With this configuration, Twilio will send the parameters with its request as URL query parameters.

The names for the two parameters mentioned in your question are

  • From (The phone number that sent the message) and
  • Body (The text body of the message.).

Other parameters are: MessageSid, SmsSid, AccountSid, MessagingServiceSid, To, NumMedia

You can read more here: https://www.twilio.com/docs/sms/twiml#twilios-request-to-your-application


If you'd like to have your own names for the GET parameters

then, probably the easiest would be to use Twilio Studio with a HTTP REQUEST widget and configure the phone number with Studio Flow instead of Webhook.

enter image description here

The HTTP REQUEST will let you make a GET request and add your own parameters to it.

enter image description here

For the values you would use {{trigger.message.From}} for your phoneNo and {{trigger.message.Body}} for your message.

enter image description here

You can read more about Twilio Studio's widgets here: https://www.twilio.com/docs/studio/widget-library#http-request