Looking for some help here. Not a coder by any means and trying to use built in functionality of Twilio to do 2 things. My goal is to respond to any SMS that is received on any of my numbers and then forward the received message to an email distro.
I have easily accomplished both of these separately.
Using a studio flow I setup an auto-responder and then using a function I integrated into SendGrid to send an email of the SMS. But when I try to combine the 2 it keeps failing.
My first approach was to call the function after the send message widget in studio but that errors out. Below is a pic of the flow and the errors.
My second approach was to just add some type of auto-respond section to my send to email function but I am no coder and cannot find any examples of anyone else doing it this way. I am just using the auto-deployed code for twilio and sendgrid integration for this function but code is below.
Any ideas??
Thanks, Drew
Twilio developer evangelist here.
It's hard to tell, but my guess here is that you have not passed the necessary data from the Studio Flow to the Function. The Function code you have there expects the event
object to have a From
and Body
parameter, which is normally passed to it by the incoming SMS webhook.
When you use the Function as a widget in Studio, you need to pass those bits of data yourself. In this case, you should pass a parameter called Body
with the value {{trigger.message.Body}}
and a parameter of From
with the value {{trigger.message.From}}
, like this: