# Twillio and Webhooks

**URL:** <https://community.particle.io/t/twillio-and-webhooks/55268>\
**Category:** Cloud\
**Created:** [March 20, 2020, 4:49am UTC](https://community.particle.io/t/twillio-and-webhooks/55268 "2020-03-20T04:49:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oraclerouter](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/oraclerouter/32/30494_2.png) [@oraclerouter](https://community.particle.io/u/oraclerouter)\
**Post date:** [March 20, 2020, 4:49am UTC](https://community.particle.io/t/twillio-and-webhooks/55268/1 "2020-03-20T04:49:55Z")

</div>

I’m trying to pass the TO and FROM phone numbers using the data filed in Particle.publish and webhooks.  
Below is what I have but I get an error `21602`Message body is required.

I tried different options but nothing seems to work and I can only get it working by specifcing the TO and FROM using the form as shown here [https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-particle-photon](https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-particle-photon)

```auto
  sms = String::format("{\"From\": %s, \"To\": %s, \"Body\": \"body\"}",setEmailString.c_str(), setPhoneString.c_str());
      Particle.publish("twilio_sms", sms, 60, PRIVATE);

```

```auto
{
    "event": "twilio_sms",
    "url": "https://api.twilio.com/2010-04-01/Accounts/ **************************** /Messages",
    "requestType": "POST",
    "noDefaults": true,
    "rejectUnauthorized": true,
    "json": {
        "data": "{{{PARTICLE_EVENT_VALUE}}}"
    },
    "auth": {
        "username": " ************************",
        "password": " ***********************"
    }
}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 20, 2020, 7:25am UTC](https://community.particle.io/t/twillio-and-webhooks/55268/2 "2020-03-20T07:25:01Z")

</div>

Not sure if this will solve your problem but you need to wrap your `%s` placeholders in escaped double quotes too.

```cpp
  sms = String::format("{\"From\": \"%s\", \"To\": \"%s\", \"Body\": \"body\"}",setEmailString.c_str(), setPhoneString.c_str());

```

You can even stick with Form over JSON.  
For that you’d just pass `{{{To}}}`, `{{{From}}}` and `{{{Body}}}` instead of the hardcoded numbers and the entired event data `{{{PARTICLE_EVENT_VALUE}}}` as body into the respective form fields.

---

<div class="post-metadata">

**Author:** ![oraclerouter](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/oraclerouter/32/30494_2.png) [@oraclerouter](https://community.particle.io/u/oraclerouter)\
**Post date:** [March 21, 2020, 2:14am UTC](https://community.particle.io/t/twillio-and-webhooks/55268/3 "2020-03-21T02:14:36Z")

</div>

@ScruffR  
Perfect, it works!

I didn’t know you can pass specific values. Thanks for the tip!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/4/64635adccc35238caa19e9b553ec3e98b163d026.png) [@system](https://community.particle.io/u/system)\
**Post date:** [September 19, 2020, 2:14pm UTC](https://community.particle.io/t/twillio-and-webhooks/55268/4 "2020-09-19T14:14:46Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
