twilio webhook custom paramters - twilio

Is it possible to define custom data in outbound SMS/IVR call and receive same data back on callbackurl/webhook. I want to receive few custom parameters (apart from what twilio sends) when my webhook is called.

Try appending the custom data as URL query parameters to the URL you give Twilio to fetch the TwiML. SMS is a different animal, since it doesn't request TwiML like voice does.
How to Share Information Between Your Applications

Related

Get Whatsapp Number of user in Twilio autopilot

I am trying to create a chatbot using Twilio Autopilot which integrated with WhatsApp. So my flow is like, if user messages on registerd number, Twilio WhatsApp senders webhook will get trigger and it will call Autopilot chatbot task. Task will process the data and it will send reply.
In all above flow I want to capture the WhatsApp number of the user who is asking the question. that number I want in autopilot, so Autopilot will send that number to Twilio function and I want to save that number in my Database using external API's call from Twilio function.
How I will get WhatsApp number inside Twilio Autopilot chatbot for user who is asking questions?
Thanks in Advance
Autopilot can respond using static actions defined within the task, but it can also send a webhook request to fetch Actions JSON from your server. That webhook request contains details about the user you are talking with, including the parameter UserIdentifier which, in a WhatsApp chat, will be the user's WhatsApp number.
If you are currently responding to tasks from Actions JSON defined in the Twilio console, you can add a webhook by using a "redirect" action at the end of a set of actions to a URL you control and then responding to that with a "listen" action to wait for the next task. Alternatively, you could just set a URL for the webhook and respond with your Actions JSON from your own app.

in case of multiple outbound calls, how to identify the call uniquely

I am creating a voice survey application so that the the users can complete the survey over voice using the DTMF inputs.
I am creating multiple calls at a given moment, but i get the call information only when the call connects and the user send the DTMF.
Is there a way, i map the received DTMF input with a unique outgoing call ?
Twilio developer evangelist here.
When you create an outbound call the object that is returned includes a sid property that is the unique identifier for that call resource within Twilio. That sid will be present in the webhook requests as the CallSid parameter. So, if you store the initial call sid against your user somehow, you can always look it up using the information in the incoming webhook request.

Triggering a Twilio function to write a record in an external service (e.g. a CRM) whenever an sms message is SENT via Twilio

What the title describes can already be done easily via programs like Zapier, so I am hopeful that it can be done through Twilio functions directly.
Essentially, I have my CRM set up so that based on certain triggers, it sends a http POST request to the Twilio URL that controls SMS sending:
https://api.twilio.com/2010-04-01/Accounts/ + twilioAccSId + /Messages.json
For the most part, this works great!
I just want a way for Twilio to then respond by using a function to write a record into the CRM (using the CRM's APIs).
I would want the record written to include things like the delivery status of the message e.g. whether it failed, or was successful). I'm also open to exploring other ways where Twilio can transmit this outbound message info to the CRM through other means, and then having a function on the CRM then write a record!
Do you have the code to share of what you are attempting and the issue encountered? Or is the question more if this is possible? It is certainly possible.
You will use a statusCallback URL of your outbound POST to the messages resource, which will fire with the statusCallback messages and make an API call to your CRM to update the customer record accordingly. You can append a URL query parameter to your statusCallback, so you know which customer record to update.
Track Delivery Status of Messages
How to Share Information Between Your Applications
Passing Custom Information via Requests to Twilio

How do i know that which IVR key option was pressed by user via Twilio API?

Hint : As I know that parameter name for IVR option is 'Digit' used in <Gather> which is sent by Twilio $_REQUEST method.
I want to fetch this $_REQUEST['Digits'] value if Twilio maintain this record?.
Twilio will make a request with the 'Digits' parameter to the action URL you specify. If there is no action URL, by default Twilio will POST to the current document. The digits are not stored anywhere on Twilio and not retrievable later.
There's a tutorial on receiving user input from the keypad with Twilio in PHP here.

How to configure Twilio send sms with callback url?

We have a requirement to configure callback URL with a custom parameter.
It's possible to configure the callback http url in Twilio console.
But we have to configure the callback url when we send sms so that when the user replies, twilio will make a call to the specified url mentioned.
Is there any way to configure the callback url programmatically?
Your timely help is much appreciated.
Twilio developer evangelist here.
You can't configure the SMS URL to be different based on different users responding to a Twilio number.
You can, however, direct this within your own system. When Twilio makes the webhook to your application it sends through a bunch of parameters including From, the number that sent you the message.
These parameters are sent as URL encoded parameters in the body of the POST request.
In your application you should be able to use that From parameter to look up your user and then deal with the incoming message for that user.
Let me know if that helps at all.

Resources