How to connect 2 callers together with Twilio [closed] - twilio

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I have a situation where I want to anonymously connect 2 callers together. The idea being, you call a phone number enter a digit (each digit corresponds to another phone number) Once you enter in your digits the phone calls the other phone number and then once that other phone number picks up, the two callers are connected.
How would I do this as cheap as possible? Is there a way to do it on Twilio to connect the 2 calls, but then once the calls are connected to not have to go through Twilio anymore?

This is possible using Twilio. The first party calls a Twilio number which then uses the <Dial> TwiML verb to call the second party, using the callerId attribute to anonymize who the call is from. For that attribute value you can use any number you have purchased from Twilio or is a validated outgoing caller ID on your account.
Generally what people do in this case is give everyone who needs to make anonymized calls their own phone number. Then you show use that for the caller ID so if the second party calls the number back, they'd also be anonymously forwarded as well.
In this case you'd be charged 1 cent per minute for the duration of the incoming call initiated by the first party, and 2 cents per minute for the duration of the leg connecting the second party.

I am fairly certain, that if you connect thru twilio, you stay connected (and incur per-minute charges) during the entire conversation.
Openvbx, which is built on twilio, does a similar thing, where you can initiate a call from the web, it calls you at your 'real' phone, you press a key and then it connects the second caller. Charges apply during the connection.
(I realize this doesn't answer the first part of the question, just answering the charge-related part)

This is a pretty basic Twilio function:
First call, respond with twiml using to get the digits, and providing a url where to send the digits to
Respond to the request with digits using a verb with to call and, like John said, set the caller ID to something else (like another twilio inbound number).
When the other party picks up, the call is connected.
Pricing-wise, you's be looking at approximately 3 cents per minute or 5 cents if a toll-free number is used.
With Twilio, you will not be able to connect the two calls and then "not use" Twilio. This is an all or nothing proposition, unless you get one of the users to re-dial the call directly.
Only alternative I can thing of, that would not require paying Twilio requires you setting up your own routing setup, such as Asterisk box. However, the cost associated with doing this is arguably greater - you have to learn telco stuff and get a decent rate on minutes from a voip carrier, not to mention supporting it. On the upside, you control your own routing here and you can get better rates, such as $0.0127 per minute here: http://www.minutehub.com/ (I have never used them and am not affiliated with them)
I've worked now in several companies using Twilio in production and have nothing but good experience with them. If you are just starting out, these guys let you focus on the problem you are solving first. Once your solution is baked, you can focus on optimizing the costs. Good luck!

Related

Twilio complication

I'm new to Twilio, and I'm struggling with one task. I want to do the following:
Customer A calls the Twilio number. Twilio forwards the call to the sequence of number (I have used twimlet findme to forward the call). In this scenario, if the first number does not answer the call. Instead, it will be forwarded to the other number in the sequence and so on.
The problem I am facing occurs when the call is forwarded to the second number when the first one does not answer. It pauses for a long time, and after some second the bell rings. At that time the customer gets confused that whether he should continue or not.
So is there any way to notify the customer that the call is being continued?
There is a second scenario where Customer A calls the Twilio number. When the call is not answered or busy, the customer gets to hear the message from the company Operator that the "person is on another call" (in different languages). Is there any way to exclude the message from the company operator?
Twilio developer evangelist here.
I think the way to solve your first question is to use answerOnBridge="true" for your <Dial> TwiML. That will keep the phone ringing until it is answered.
For your second question, you should set a timeout on the call so that it doesn't reach an operator message.

Bidirectional connection [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I want to know how can we have a bidirectional connection physically and electrically for example how can we send and receive signals at the same time in telephone wire without interference?
thanks for your answers!
Although your question is off-topic the answer is pretty simple.
You have multiple wires. For a signal you need at least two. One for the signal and one to have a common reference the signal refers to.
So either you have at least 2 signal lines so you can send and receive at the same time or you have 1 signal line and both sides send/receive alternatingly.
The term you are looking for is 'Full Duplex'. Communications is a huge topic and it would take a book on the subject to give a complete answer for all cases, but we can generalise a simple answer.
I would not consider this completely off topic here as the same is true for example by two computer processes sending data between each other over some media, perhaps shared memory.
With very few exceptions, full duplex communications requires that there is some form of separation of the data on the channel between multiple parties.
Separation could be by frequency band, separate media (multiple carrier frequences, multiple wires or fibres), by time, coding scheme or other methods. Search FM (frequency modulation - and variants thereof), TDMA (time division multiple access), CDMA (code division multiple access), etc.
In the care of analog telephones it's time; i.e. more than one person talking at the same time will have trouble understanding one another.
Analogue telepones are one of the few mediums where the data is not modulated on a carrier and the media is shared without any controls other than the individuals at each end cooporating.
Full duplex communication can introduce another problem; the send mechanism (e.g. microphone) can coupled to the receive mechanism (e.g. loudspeaker).
E.g. in the case of a phone this is by the media and the room each person is in. This means that because the two are coupled and it takes time to send the message to the other end, echo can be introduced which must be eliminated (echo cancellation) or the message will get corrupted by the returning delayed copy (the echo).

TwiML: create an automatic navigation & wait before playing the message

I am using Twilio to call Shops land-lines and play a message.
Some of the shops are using answering-machine with navigation to a specific departed: "press 3 for customer service..."
I would like to create an automatic navigation: When the system will recognize an answering machine I will use a digits sequence for each shop to reach the right department.
My problem is that after the system finished navigating
to the right department I don't know how long it will take the person in that department to pickup the phone and only after that to play the message.
This is what I am trying to do:
<Play>
<digits="wwww3">
</play>
<Pause length="?"/> // I don't know how long to wait.
<Play>
https://mySite/message.mp3
</play>
Is there an option to know when this person picks up the phone?
There is no easy answer. This is why most telemarketing companies use call screening (see below), or just play their message no matter what when someone answers.
Telemarketing is a multi-million dollar industry, and if this type of system was readily available or easy to develop companies would use it, however, they do not.
The only way you can be 100% sure a human has answered the phone and is listening is call screening as explained here: https://www.twilio.com/docs/tutorials/walkthrough/ivr-screening/php/laravel
While not a complete match for your query it is also covered here
https://www.twilio.com/help/faq/voice/can-twilio-tell-whether-a-call-was-answered-by-a-human-or-machine where it says
One alternative to AMD is Call Screening, aka “Human Detection”.
That is it for easy implementation. Outside of that you could code your own machine that could listen into the call via conference to try to identify when a human speaks and then process it. However, this type of system is very expensive and complex from what I have seen and even then it is not 100% reliable.

Specifying multiple Twilio numbers when sending an SMS to spread load over all numbers

I am new to Twilio and was reading that the limit is 1 SMS per Second per Number.
If you have more phone numbers, then the overall sending rate increases.
My question is if we need to specify multiple numbers in the code in order to take advantage of the increased rate with having more numbers, or is this taken care of automatically by Twilio, even when I specify only one number in the code?
It is not clear if I manually have to Round Robin across all my numbers myself, or if Twilio does this for us.
I am using PHP to do this.
Twilio evangelist here.
You will have to write the code that round robins across all of the numbers in your account. This should be pretty straight-forward.
What I would do is put all of those numbers in an array (you can use the REST API to get the list of all of your Twilio phone numbers), and then in your message sending loop, just use a counter to keep track of your place in that array. Once that counter reaches the array size, just reset it to 0 to start over at the beginning of the array.
Hope that helps.
Over the years the answer to this question has changed. There is now a Twilio service called Copilot which enables all kinds of number intelligence. See the docs here for examples of how to use it. That docs page lists it as a "public beta" (though it also suggests sending API queries to the 2010 version of their API, so it seems a bit outdated).
Edit: Be sure to read the docs regarding the response, since the Copilot behavior is different than the standard message sending behavior:
There is a slight difference in API response when specifying the MessagingServiceSid parameter. When you only specify the From parameter, Twilio will validate the phone numbers synchronously and return either a queued status or an error. When specifying the MessagingServiceSid parameter, Twilio will first return an accepted status.

How to recognize fax numbers?

What should be the best way to recognize that a number is connected to a fax without actually sending faxes around ?
I suppose that a short phone call can be made: the goal is to determine if a number that is declared as a fax line is really a fax line, working and available.
If you can make a phone call, many faxes create a "Fax Identification tone".
This signal may be sent by the Terminating FAX machine anywhere between 1.8 to 2.5 seconds AFTER answering the call. The CED signal consists of a 2100 Hz tone that is from 2.6 to 4 seconds in duration. The CED tone is useful for disabling any echo cancellers on the line.
The CED also incorporates a "silent" interval following the 2100 Hz tone. This interval lasts from 55 to 95 (75 +/- 20) mS. Following this interval, the Terminating FAX machine will initiate the Pre-Message Identification procedures by transmitting a 300 BPS "Line Turn-around" preamble.
Some older faxes do not support that though, no idea how they can be triggered (i.e. by you sending a tone first, but that could be really annoying if you have a phone instead of a fax number)
I understand your question as that you have a list of fax-numbers in your customer database and want to verify that those numbers still are valid.
Then you could use TAPI to programatically call those numbers and check if its a fax that answering, no need to actually send any fax, just connect and ask the device (fax) what capabilities it has.
Here are Microsofts information about their TAPI
An easier way could be to have a fax modem on the com-port and using ATI-commands to call the device and send ATX3D and see if the device answers with ATA. (Or something similar, it was ages ago I programmed modems..)
It's essentially impossible.
They make line-sharing switch devices. For example, visit http://www.faxswitch.com/ to see their offerings.
The line appears like a voice line until you send a fax recognition tone. Then the line switches to a fax machine, if one exists.
So, a single number can be voice and fax.
A quick and dirty way of testing if a number is a fax number would be to google (using some API) for "Fax [number]".
e.g.
http://www.google.co.uk/search?q="Fax+01422+329262"
Not in New Zealand at least.
Here, Fax-Numbers do not differ from normal numbers in terms of namespacing.
A fax number may be only 1 digit ( the rightmost ) different from their normal line, or even a company may not have distinct FAX/Phone lines, and they just share a line and use tone detection to initiate fax protocol instead.
Also, you don't need to register with anybody to have fax services work on your phone line, so there's no index you can look up to see if its a fax or not. The only way to know is initiate a call, and see if you get a fax response, and even then, if the Fax happens to be turned off, you'll get a false negative.
I think your question may turn out to result in hunting for phantoms.
Oh, and for additional fun, you may have desktops with their dialup modem plugged into the wall merely emulating a fax device :). If you don't want to include these as "fax machines". you will be most likely out-of-luck.
First, there isn't anything inherent in the number that identifies it as a fax line. Even the phone company doesn't know - it's just a device attached to the wall jack, by the customer.
At some point you just have to trust the user. However, try the following ideas as well:
On each fax, publish a number (preferably toll-free) where the recipient can call to cancel. In some localities this might be a requirement anyway - "unsolicited" faxes are considered abusive in much the same way as spam since they can entail both material and bandwidth costs for the recipient. This will protect you in the eventuality that someone subscribes a number that doesn't belong to them.
Add some kind of error threshold to your software that will halt fax attempts once n attempts fail, and flag the number as inoperative. If you have some other way to contact the user, you could notify them of this event. The same principle works for e-mail addresses - I've received snail-mail notifications from companies when I changed e-mail addresses and forgot to notify them; once the e-mail had bounced a few times, they sent a courtesy letter to remind me to update it.
Many old fax lines are set to automatically pick up even on a voice call, so you could just call and check. On the other hand, it won't work on a lot of new ones, so while you could tell that one is a fax line, you couldn't tell it wasn't.
I'm sure a fax is a modem, so if you connected to it - using AT codes maybe (how 1990's!), you could determine from the response codes that there was a fax there - but you still have to make the call, make the negotiation etc - just dont send a page.

Resources