Closed aryo closed 5 years ago
Hi @aryo
We support custom parameters via REST API. You can refer to the documentation here for more details.
To pass in additional custom data to your flow, add a Parameters= parameter.
curl -X POST “https://studio.twilio.com/v1/Flows/FW9d816f0b90d2a10b913868462e339d29/Executions” -d “To=+1646221xxxx” -d “From=+1331481xxxx” -d “Parameters={\“name\“:\“zeke\“}” -u ACCOUNT_SID:AUTH_TOKEN
Thanks.
@aryo
The documentation I referred above is for the Studio REST API. Is that what you are using?
Thanks for the quick reply @kbagchiGWC
How would we do this via the call resource endpoint?
e.g.
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json \
--data-urlencode "Url=http://example.com/call.xml" \
--data-urlencode "To=client:alice" \
--data-urlencode "From=+15017122661"
Hi @aryo
I did not find any documentation on that. Can you please open a support ticket by following this link https://support.twilio.com/hc/en-us/requests/new? One of our support engineers will be able to help you on this.
Thanks.
I see. Will do that.
Thanks for your help @kbagchiGWC!
Did you get a solution to this from Twilio's support? I'm trying to figure this out too.
Hi @highku
Currently the REST API for creating Call Resource doesn't support embedding custom parameters when making calls to Voice clients directly. However there is a workaround by specifying TwiML in the Call Resource API:
This is an example of TwiML response that sends custom parameters to the client
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="client:alice">
<Client>
<Identity>bob</Identity>
<Parameter name="caller_first_name" value="alice" />
<Parameter name="caller_last_name" value="smith" />
</Client>
</Dial>
</Response>
When creating the Call Resource using the REST API, add Twiml
to the request body
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Calls.json \
--data-urlencode "Twiml=<Response><Dial callerId="client:alice"><Client><Identity>bob</Identity><Parameter name="caller_first_name" value="alice" /><Parameter name="caller_last_name" value="smith" /></Client></Dial></Response>" \
--data-urlencode "To=+15558675310" \
--data-urlencode "From=+15552223214" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
You can tweak the numbers based on your business logic but basically what the above does is that once the call to 15558675310
is connected, Twilio will make another client call to bob
which is action specified by the TwiML. This way bob
will be able to see the custom parameters upon receiving the incoming call.
This is a little bit awkward since instead of adding custom params directly to the To
request param, you will have to make a call to a number or a client first since the To
param is required by the API.
Let me know if this makes sense to you.
@aryo FYI
Cheers, -bobie
Hi guys,
The 3.x instructions specify how to send custom parameters to the client via a twiml response...
Is there any way to send the custom parameters when making a call to a client via the voice REST API (by creating a call resource)?