Twilio Caller ID set for outgoing Calls - php

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.

Related

Twilio Two different Voice REQUEST URL for inbound call and Twilio Device Client?

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.

calling to twilio number from mobilephone

I want to take my phone, call the twilio number and then talk with the person in the other side; and as the same with the sms.
I don't want "url" apps, or phone apps... (I made this that actually works http://luiscallcenter.netne.net/callcenter/index.php)... but I don't want use this.. I want to use twilio as another phone number... ...
can you help me with some reference?... I read the API but all that is about web apps, but I don't want this and I'm confused.
Basic Call Forwarding
http://twimlets.com/forward?PhoneNumber=123-123-1234
In the above URL, replace 123-123-1234 with your cellphone number. Then set this URL as your twilio voice URL. Then all calls coming to your twilio number will be forwarded to the given number. This service is offered by twilio itself.
(For more details, visit here)
Twimlets Service by Twilio Labs
You can use this website provided by twilio to generate urls for some common use cases such as forwarding to a cell number, echo a message etc.
When using this feature, you dont have to do any actual coding. Just replace the necassary parts in the provided URL and set this URL as the voice URL in twilio.

Is it possible for me to exchange information with Twilio APIs?

I'm trying to identify the user who is making Twilio requests from my system. Is there a way I can encrypt the information of this user, send it to Twilio along with the allowed parameters & receive the same along with Twilio's response?
EDIT: I may not have been very clear. I'm trying to make calls using Twilio's API from a web-app (PHP). I need to send the user (who is trying to establish the call)'s details & our API key to Twilio so that I can identify the user when I receive the response from Twilio.
You can include custom URL parameters in Twilio's webhook callback URL. Although the Twilio system itself will not make use of this information, it will be passed back to your php application when the call is answered. You can use this information to correlate the call to a user or other application specific concept. Here's an example:
$call = $client->account->calls->create(
'9991231234', // From a valid Twilio number
'8881231234', // Call this number
// Call this URL when a call connects and include the custom user_id parameter
'http://www.yoursite.com/handle_call.php?user_id=41423’
);
You can find more information about how the Twilio REST API and webhooks work together in the Twilio Skills training.
I doubt if it is twilio's responsibility to store additional information that you need to be otherwise handling yourself on your system. Why would twilio take operational overload from your end? Twilio probably has a confirmation token or request id for the twilio request that your system makes (returned via XML/ Json by its API server). You can take that ID and store it against the user_id inside your database (SQL / Mongo / Redis). Use that table to extrapolate information you need such as.
The number of requests each user made initiated.
The kind of requests made.
What time each request went out.
Result / Response from each request.
Hope this helps.

Unable to get Twilio "call-recording" url

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!

php: how twilio transfer incoming call to particular client browser under what specific conditions

I am going to integrate twilio Voice for making outbound calls and receiving incoming calls to my web Application.
When someone calls from traditional phone to one of twilio powered phone number, twilio receive the incoming connection through twilio device and send Asynchronous HTTP request to voice URL configured for that particular number and execute the expected Twiml Instructions.
But here, the question is when i want to integrate this functionality of receiving incoming calls or connections to twilio number into my web application for multiple users , then how my application will distinguish that call is receiving on a particular number alongwith the registered client.
I believe you have the process a bit backwards:
When someone calls from traditional phone to one of twilio powered phone number, twilio receive the incoming connection through twilio device and send Asynchronous HTTP request to voice URL configured for that particular number and execute the expected Twiml Instructions.
When a call is placed to a Twilio number, that call is routed directly to the voice URL (not through one of the device clients). The only time what you're describing happens (a new 'connection' creating a request from the device to the voice URL), is when the device makes a call.
the question is when i want to integrate this functionality of receiving incoming calls or connections to twilio number into my web application for multiple users , then how my application will distinguish that call is receiving on a particular number
Since all incoming calls go directly to your voice URL, the script/application/whatever that processes that request can route the call on whatever criteria is needed.
For example, if you point multiple virtual numbers to the same voice URL, just check the incoming 'To' number, and map that to the correct device (using <Dial><Client>name</Client></Dial>).

Categories