Twilio : Setting phone number for the outgoing call widget - twilio

In the below widget, the field NUMBER TO CALL cannot be edited.
So, how do we set the value of the phone number that needs to be called

You can't change the NUMBER TO CALL in Twilio Studio for this case.
The {{contact.channel.address}} value comes in as the To parameter for the Trigger widget when you make the POST request to Studio's REST API.
So, you'll have to pass the number when you trigger the flow.
Docs: (https://www.twilio.com/docs/studio/user-guide#rest-api)

Related

Slack API - Detecting user in a call?

Is there an endpoint in Slack API to detect a user (AKA me) is in a call? getPresence just returns 'active' and 'away' which is not helpful - I can be active but not in a call. I tried getting user status, that is of no help either
There's no API that will return that information at this time. The calls.info method would return a list of users in a specific call but you'd need to know the call id for that. Something as simple as knowing if any given user is on a call would be a great feature request for the users.getPresence method. Happy to pass that along!

Studio MAKE HTTP REQUEST return sid

This is from a Studio Flow.
I'd like to return the conversation sid. The same "sid" that is used in the Twilio log system. This sid is returned when the conversation is created via a REST call. On the screen below, you can see that I've figured out how to return some flow.data values using this widget. When I look through the available sids (the list is long, but there were approximately six different variable.variable.sid type variables to choose from), none of them seem to return the value that I am looking for. I did add all of them into the JSON return packet and only two returned values. Both values were not what I was looking for.
I'm hopeful that it is something simple like {{message.sid}}, but just haven't discovered the correct variable name yet.
You want: {{flow.sid}} for the Studio Execution SID.

How does the Twilio call object report prices when the call isn't finished?

The Twilio Call API says for price that:
Populated after the call is completed. May not be immediately available.
What does "May not be immediately available?" mean in this context? price set to null? No price key in the response object?
Twilio developer evangelist here.
I just made a test call and the price was set to null before it was updated to a real figure.

Twilio hangup call through REST API not working?

How to hang up the call whent it's status is in queued state(ringing or initiated)? None of the codes below have any effect on call, call continues to ring untill receiver picks up.Sometimes when agent realizes they are dialing wrong number they need a way to hangup the call in the middle of ringing.
PHP code
$client->calls($callRecord->call_sid)->update([
'status' => 'canceled'
]);
$client->calls($callRecord->call_sid)->update([
'status' => 'completed'
]);
$client->calls($callRecord->call_sid)->update([
'url' => 'mywebsite.com/tw-hangup'
]);
See the following Twilio Documentation:
Voice API: Call (the last paragraph is most relevant)
https://www.twilio.com/docs/voice/api/call
When you redirect an active call to another phone number, Twilio creates an entirely new Call instance for that new phone number. The original call is the parent call, and any additional number dialed establishes a child call. Parent and child calls will have uniquely identifying Call SIDs.
Note that any parent call currently executing a is considered in-progress by Twilio. Even if you've re-directed your initial call to a new number, the parent call is still active, and thus you must use Status=completed to end it.
Unanswered child calls cannot be canceled via the REST API, but the parent call can be modified to point to new TwiML. This action will end the child call.

Twilio Redirecting in-progress call to specific URL

I need to modify current in-progress call.
if A calls B, they are connected and have a talk, I need to redirect B to some Twiml URL, and to disconnect A from call (I can do this via JavaScript SDK .diconnect() function, since I am the "A" caller). I am using an example from Twilio docs (php SDK v4.x):
$call = $client->account->calls->get($callsid);
$call->update(array(
"Url" => "http://path-to-twiml.php",
"Method" => "POST"
));
but nothing happens. Is it possible to somehow do what I need without using Conference Twilio options?
PS: adding "Status" => "complete" parameter to update options causes disconnect for both sides of a call, since I need to disconnect only 1 (the one who initiated the call) and to leave other (redirected to specific twiml url)
Twilio evangelist here.
From the code that you posted, I'm guessing that the callsid you are modifying is actually Caller A, not Caller B. In your scenario, A and B are each going to have their own seperate callsid, where Caller A is the "parent" and Caller B is the "child".
To get the child sid, you can include a URL in the statusCallback parameter in your <Dial> verb which will get requested when Caller B answers. The callsid parameter of this request is Caller B's sid. You'll also receive a parameter named parentCallSid which is Caller A's sid and that lets you correlate the child leg (Caller B) with the parent leg (Caller A).
Once you have child sid, you can modify it using the PHP library.
Hope that helps.

Resources