I am developing a Twilio based application for a online campaign management system, and for each campaign there will be a twilio number and a target number. Whenever somebody will call to a twilio number (assigned for a particular campaign), it will be forwarded to the particular target number. There are also two Check-box field (one for Call-Whisper and another for Call-Recording) for each campaign.
I got a reference for Call-Whisper and Call-Recording from :
Call Screening and Recording
But unable to understand how to get the call-recording url from this tutorial.
Kindly suggest.
Twilio evangelist here.
You will need to add an action attribute to the <Dial> tag. This attribute takes a URL as a parameter, and once the call completes Twilio will make a request to that URL. That request will contain a paramater called RecordingUrl, which will have the URL of the recorded file. So configure the <Dial action=""> to some URL on your server, and then you'll get the request so you can download/store the recording.
You can see more about this in the TwiML documentation for the Dial verb.
Hope this helps!
Related
I had call tracking set up on my system following this tutorial https://www.twilio.com/docs/tutorials/call-tracking-php-laravel, i have created twiML app with Voice REQUEST URL configured for this call tracking purpose.
Basically on my system i have list of users with their own personal number and assigned twilio number so whenever call comes in to one of twilio numbers, twilio posts to Voice REQUEST URL and in that url i have logic for call forwarding to their personal number, recording call log etc.This is working fine.
Now my new requirement is ability to call through browser to any number, I read this tutorial https://www.twilio.com/docs/tutorials/browser-calls-php-laravel . It seems i need to use Twilio Device Client.
My question is it fine to create new different twiML app for this purpose so that i will have separate Voice REQUEST URL where i can put apporiate logic to call destination number OR i should use same twiML app and within same REQUEST URL of my system i need to put logic for two different purposes? what could be recommended way of doing this?
Thanks in advance for any suggestion
"create new different twiML app for this purpose so that i will have separate Voice REQUEST URL where i can put apporiate logic to call destination number"
Your first answer seems the best. Keeps your code and logic cleaner.
I need to save the call recording details including the audio file to database while making a call.
This is my twiML file.
<Response>
<Dial record="record-from-ringing-dual" recordingStatusCallback="https://example.com/record_data.php" action="https://example.com/test.php" callerId="xxxxxxxxxx">
xxxxxxxxxx
</Dial>
</Response>
What should I do in record_data.php file to save the recorded details to the database?
Can anyone help me on this? Thanks in advance.
Twilio developer evangelist here.
When you receive the recordingStatusCallback webhook, Twilio will send the following parameters in the body of the request.
AccountSid The unique identifier of the Account responsible for this recording.
CallSid A unique identifier for the call associated with the recording. This will always refer to the parent leg of a two leg call.
RecordingSid The unique identifier for the recording.
RecordingUrl The URL of the recorded audio.
RecordingStatus The status of the recording. Possible values are: completed.
RecordingDuration The length of the recording, in seconds.
RecordingChannels The number of channels in the final recording file as an integer. Possible values are 1, 2.
RecordingSource The type of call that created this recording. For recordings initiated when record is set on <Dial>, DialVerb is returned.
The RecordingUrl is where you can download the recording from to store on your own server.
Let me know if that helps.
What I am trying to accomplish is quite simple. I want to store all received SMS messages from a Twilio number in a database. Upon checking Twilio's documentation, their TwiML word should be able to do this, but no attribute relates to this:
https://www.twilio.com/docs/api/twiml/sms
Twilio developer evangelist here.
When your Twilio number gets sent an SMS, your application receives a webhook at the URL you supply in the settings for the number. For each messages, the webhook sends a number of parameters telling you about the message. The documentation for that can be found here: https://www.twilio.com/docs/api/twiml/sms/twilio_request.
You might want to take a look at our PHP Quickstart tutorial which will give you a good idea of how to get the details from the request. You will then just have to pick which attributes you want to store in your database.
Let me know if this helps.
I have played around with database integration on Twilio, but how would I be able to ask for two inputs such as tracking number and password, and then for a status to be read if both are correct?
My main aim here is to protect our clients who need to get updates on their cases so that others cannot just randomly press a load of numbers and inadvertently get someone's update messages.
Do you have any coding example?
I've been adapting their PHP examples which are given in their How-to guides.
Thank you very much in advance for your help,
Dan
Twilio evangelist here.
So the pattern you can use in this scenario is basically something like this:
An inbound call causes Twilio to request the URL you have specified for your Voice Request URL. That URL returns TwiML.
https://www.twilio.com/docs/api/twiml
Maybe the <Say> verb telling Twilio to prompt the user for the first input (lets say tracking number) and the <Gather> verb to listen for the caller to enter tones. As part of the Gather verb you need to include the action parameter which tells Twilio what URL to request once the Gather completes.
<Response>
<Gather action="/gather-tracking-number.php">
<Say>Please enter your tracking number</Say>
<Gather>
</Response>
Once the user enters their tracking number and the Gather completes, Twilio will request the URL specified in the Gather verbs action parameter. As part of the request Twilio will pass you the digits the caller entered. Your app needs to persist those somehow. Database, session, whatever.
This URL also needs to return TwiML with the next prompt in it.
<Response>
<Gather action="/gather-passcode.php">
<Say>Please enter your customer pass code</Say>
</Gather>
</Response>
Also, as a cheap way of maintaining state across the request/responses, you can use the querystring. For example to pass the tracking number to the next page in your workflow you can throw it in the URL like this:
<Response>
<Gather action="/gather-passcode.php?trackingnumber=" . _REQUEST["Digits"]>
<Say>Please enter your customer pass code</Say>
</Gather>
</Response>
Hope that helps.
In my web application I have used Twilio api for making calls,
params = {"PhoneNumber": 'xxxx123'};
params = {"callerId": 'aaaa987'};
params["PhoneNumber"] = 'xxxx123';
params["callerId"] = 'aaaa987';
Twilio.Device.connect(params);
But in receiver phone/twilio call logs did not get from number aaaa987, it is some other number like xyz567 every time.
How can I set from number for Twilio outgoing calls ?
Twilio evangelist here.
So to make sure I understand your question:
You want to use the Twilio Client for JavaScript to make a phone call from a browser to a regular PSTN phone
You want to have the Client pass parameters to Twilio to set the phone number and caller ID of the call to the PSTN phone
Assuming I understand your question correctly, it looks like you are on the right track, passing an array of values into the Connect function. Now, what Twilio will do with that array is we will take each item in the array and convert it into a parameter that we send with the HTTP request we make to the Voice Request URL you have configured for your TwiML app.
Based on the tags you set for your question, it looks like you are using PHP? If that's correct then you would just set the Voice URL to a PHP page that you have hosted on the internet.
That PHP page can use the $_REQUEST object to access the HTTP parameters Twilio is including in its request and use them to dynamically generate TwiML. In your case since you want to have Twilio dial out to another phone number, you are going to need to generate TwiML containing the <Dial> verb.
Here is a sample that shows how you can use the Twilio PHP Helper library to generate TwiML:
$response = new Services_Twilio_Twiml();
$response->dial($_REQUEST['PhoneNumber'], array(
'callerId' => $_REQUEST['callerId']
));
print $response;
In this case I am grabbing the PhoneNumber and callerId parameters from the HTTP request made by Twilio and injecting them into the dial method. This would result in the helper library generating some TwiML that looks like this:
<Response>
<Dial callerId="aaaa987">xxxx123</Dial>
</Response>
Your PHP page returns the generated TwiML to Twilio in response to Twilios HTTP request. Twilio then executes the TwiML making cool things happen, like a phone call to the number you've specified.
If you want a bit more of a step-by-step walk-through for Twilio Client for JavaScript, I'd suggest talking a look at the Twilio Client for JavaScript Quickstart. Its available in PHP and will take you through using Client for both inbound and outbound phone calls, including setting up a server side application in PHP to generate and return TwiML and also passing parameters into that PHP file.
Hope that helps.