Twilio call forwarding - php

I have a question about Twilio's call forwarding concept.
I want to create an application that lets users forward their existing numbers to Twilio, which processes the necessary information, and forwards the call back to the user.
However, when I try to implement this, an infinite loop happens: The call is forwarded to Twilio, which forwards the call back to the user, which forwards the call to twilio...
How would I implement this on the Twilio side, since it is difficult to implement any code on the user side?
Here is my code on Twilio that forwards the call back to the user.
<?php
header("content-type: text/xml");
?>
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<Response>
<Say>Hello User</Say>
<Dial>+1973XXXXXXX</Dial>
</Response>

This is tricky. How are users forwarding their existing numbers to Twilio?
The problem is that you want a rule for your cellphone like, "Forward all calls from my cellphone to my Twilio number, unless they are coming back to my cellphone from Twilio." I'm not sure if the call forwarding mechanism for your existing numbers is that sophisticated.
On the Twilio side, you could try returning different TwiML based on whether you've "seen" the call before (is it being forwarded for the first time, or the second time)? But you would have to forward the call to a third number, to avoid the forwarding problem you are already running into.

It is not possible to forward calls to a Twilio number and have that number call you back if you've set up call forwarding on your phone. Conditional call forwarding can only be used for unanswered or busy calls, and for some providers, certain numbers. However, AT&T and Verizon do not allow "forward all numbers but one" for call forwarding.

you are working with twilio call it is with the best solution that we have:
"But you would have to forward the call to a third number, to avoid the forwarding problem you are already running into."

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.

Trying to figure out a how call works in twilio

As subject says I am reading api docs for twilio but even after brainstorming for 2 hours I am still unable to figure out exactly how can I receive a call from twilio on my web application and answer the call with my own voice like we do in a real phone.
I know how to respond a call when someone call your twilio number but that's only text to speech conversion like their "Hello Monkey" example application but nothing so far about answering a call using their API.
Can anyone please explain how can we do that? Not everything, just main concept and few references if possible
I am using Laravel so would be good if it's in php
Twilio evangelist here.
I would suggest working through the Twilio Client for JavaScript Quickstart. This will walk you through both the server and client side code needed to build a phone in your browser, showing you how to both make outbound calls from the browser to a PSTN phone as well as receive incoming PSTN calls in the browser.
The magic that you are looking for in either of those cases is the <Dial> verb. When an incoming PSTN call comes into Twilio, you can use the Dial verb to tell Twilio to dial and bridge that call with a Client instance:
<Dial>
<Client>jenny</Client>
</Dial>
When and instance of client make an outbound call and wants to connect to a PSTN phone number you again us the Dial verb:
<Dial>
<Number>+15555555555</Number>
</Dial>
The quickstart shows in more detail how this works.
Hope that helps.
You tried the Twilio PHP lib? As for Laravel... Incoming call? No problem!
Please try to use Google before asking questions! I think one important trait to any programmer is the ability to organize the idea of "what you want", and then google each step to get it that you want...

Twilio IVR Database Integration Two Inputs?

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.

TwiML not working

We're building Call Tracking website using Twilio API.
The goal of our website is, when someone call a Twilio number (i.e (855) 329-5712), that call will be redirected to a specific predefined number.
The following TwiML we have generated for the same:
<Response>
<Play>//s3.amazonaws.com/calltrackingdashboard/upload/greetings/d9e5234534c5ca818e26225ed7e15809.mp3</Play>
<Dial record="true">
<Number url="http://www.filenewtrack.com/callfrds/whisper/170">+919674683063</Number>
</Dial>
</Response>
The Call is not connecting to the receiver properly.
Call just redirecting properly and the Caller heard the continuous ringing though the receiver receives and start communication. Even Call Whisper is not working.
Any help in this regard will be highly obliged.
Thanks in advance.
Twilio evangelist here.
In addition to checking the App Monitor, I'd also suggest checking the call logs and see what Twilio is logging as the result of the call.
It looks like you are trying to dial an Indian number, so if nothing interesting shows up in the call logs or the app monitor, my suggestion would be to drop our awesome support team an email at help#twilio.com. If possible, include in your email the Call Sids of several calls where you experience the issue so the support team can dig into them for you.
Hope that helps.

Twilio sms question

Uptill now I have been using Twilio for phone calls. Now I want to be able to have a network monitoring tool that texts when there is a problem to a number. I would like to make it so that when twilio receives the text it will execute the script that I have put into its URL...I really don't know how to get started with sms it seems very hard and complicated as compared to phone calls...Any help on the sms is greatly appreciated to get me started.
If you've already figured Twilio voice calls, you'll find SMS easier once you figure out what they're doing. Which is essentially:
Carrier delivers an SMS to Twilio for a number you're renting from them.
Twilio makes an HTTP POST or GET (you choose) to the URL you setup in their web admin. The content of the text message will be a parameter in there.
You do whatever you want with the POST or GET, returning a TwiML if you want an SMS reply sent or nothing if not.
Note, Twilio can't execute a script for you, unless it's TwiML, in which case you're just returning TwiML as the response to the HTTP call from #3. So if you want to do something in response to an SMS, you'll need build that something into the logic that handles the URL you've given Twilio. If you're still lost a bit, tell us about how you're trying to do this, e.g., you've a Rails app, a PHP website, or just a Bash script you want to run and nothing else yet...
Why not avoid Twilio and have your network monitoring tool execute the script itself?

Categories