Twilio: Making conference name dynamic with REST apis - twilio

I am working on making conference calls from twilio client using REST apis.
I am using java helper libraries to call each participants and as they accept they are put to the same conference room. I am successful up to this. The code which returns the xml for conference, I have put in python following the code of server.py present in android sdk.
Currently in server.py I have hard coded the conference name, i.e anyone who tries for a conference will end up in same conference room.
So I want to make it dynamic. I want to pass the conference name from my java code to the url where server.py and the conference xml is present.
I have tried the following.
I tried adding one extra parameter to the call parameters as
callParams.put("To", user); // Replace with a valid phone number
callParams.put("ConfName", "kevin");
callParams.put("From", my_twilio_num); // Replace with a valid phone number in your account
callParams.put("Url", "https://dyno-name-conference.herokuapp.com/conference");
final Call call = callFactory.create(callParams);
where ConfName is my intended conference name. and I tried to retrieve it in server.py like
ConfName = request.values.get('ConfName')
response.dial(callerId=caller_id).conference(ConfName)
But the ConfName is not getting retrieved.
Is there a better approach for this.
I thought of passing an extra parameter along with the url as I see from the answer here. But I am not successful in that too.
May I know if there any correction in above approaches or a different approach for this..
Thanks in advance.

I managed to get it work.
I used the url as
call__Params.put("Url", "https://dyno-name-conference.herokuapp.com/conference?conf_name=kevin");
and in server.py I accessed it as
conf_name = request.values.get('conf_name')

Related

Dynamic destination phone assign, at incoming call start

I am looking into the possibility to implement call tracking with Twilio.
What I would need is that right at the start of an incoming call I would like to be able to change the destination number for that call.
How is this achievable with Twilio via API?
Reading the API docs I found the that there is a real-time call and message routing feature (here) and followed the example (here) but it's not what I would like to achieve.
Thanks ahead for any suggestion and help!
--Steve
Twilio developer evangelist here.
You absolutely can dynamically change the destination number for calls on Twilio. When you are forwarding calls you use the <Dial> noun in TwiML like so:
<Response>
<Dial>YOUR_NUMBER_HERE</Dial>
</Response>
However, if you serve your TwiML dynamically you can return whatever number in the <Dial> tag that you want, based on whatever conditions you want. For example in Ruby using Sinatra:
post "/voice" do
if params["From"] === SOME_SPECIAL_NUMBER
number = FORWARDING_NUMBER_1
else
number = FORWARDING_NUMBER_2
end
"<Response>
<Dial>#{number}</Dial>
</Response>"
end
Let me know if this helps at all.

Customize Twilio's click-to-call, transcribe and collect statistics

I'm using Java but the question is language-agnostic, so I posted it under twilio-PHP tag too.
My application needs to connect two customers: A and B. I want to transcribe the conversation and find out whether one of the parties did not pick up and screened the other to voicemail.
I'm following the steps in the click-to-call-tutorial
However, it looks like the Rest API supports recording but not transcription. I successfully can do:
Map<String, String> params = new HashMap<String, String>();
params.put("From", myTwilioNumber);
params.put("To", customerAPhoneNumber);
params.put("Url", "http://MyHandler.jsp");
params.put("IfMachine", "Hangup");
params.put("Record", "true");
Call call = client.getAccount().getCallFactory().create(params);
which gets the entire conversation recorded, but not transcribed!
As a side note -
params.put("IfMachine", "Hangup");
indeed hangs up, when reaches voicemail, but not before leaving a voicemail with random noise. Looks like Twilio's "probing" the response, and by the time it understands it got to voicemail, background noises have been recorded. Which is terrible user experience. Any advice?
Additionally, my call handling servlet does:
TwiMLResponse twimlResponse = new TwiMLResponse();
Say sayMessage = new Say(
"Hi, customer A, stay on line to speak with customer B?");
twimlResponse.append(sayMessage);
Dial dial = new Dial(customerBPhoneNumber);
twimlResponse.append(dial);
But when I'm looking at the TwiML Verbs , there is no place where I can set params.put("IfMachine", "Continue") . So the field call.getAnsweredBy() is null for the second call. In other words, I cannot know whether conversation between customer A and B ever happened.
Additionally, [TwiML Verb Record] ( https://www.twilio.com/docs/api/twiml/record ) does allow transcription, but if I do
twimlResponse.append(new Record());
it stops the conversation and records one of the customers.
So I cannot direct the REST API to transcribe, and TwiML Verbs does not even record the conversation in a way I want.
Can anyone help?
Thanks.
Twilio developer evangelist here.
I'm afraid that when recording both legs of a call, using the REST API, then transcription is not available. Transcription is only available on single messages recorded by the <Record> verb when the recording is under 2 minutes long.
I'd recommend recording the call and downloading the file to be sent off to a third party transcription service in order to transcribe longer, 2 legged calls like that.
In terms of the answering machine detection, it is an experimental feature and requires Twilio to listen to the first few seconds of a call to work out whether it is a machine or not. A good alternative, which can work as part of your <Dial> verb as well, is to use call screening. This is a good article on the pros and cons of AMD, as well as a good description of using human detection by call screening.
Let me know if this helps at all.

Twilio connection parameters missing "To" parameter

I'm developing a Rails Twilio-based application and want to show to my user the number that the caller is calling (because in my application, a user can be associated with multiple numbers).
Here's the code:
Twilio.Device.incoming (conn) ->
$("#log").text("Receiving call from:" + conn.parameters.From)
$("#log").text("Calling to:" + conn.parameters.To)
ringtone.play()
$('.answer').click ->
ringtone.pause()
# accept the incoming connection and start two-way audio
conn.accept()
However, the conn.parameters object does not have a To parameter as the documentation says.
For now, I can get the number being called only server side, with params["Called"], but that is not what I need.
Any ideas ?
Megan from Twilio here. I'd like to share some of what I learned after recently getting Twilio Client up and running.
The way I imagine your call flow is that a 'user' in your application represents an agent with multiple sales lines connected to Twilio numbers configured to a TwiML app. When a customer or the 'caller' finds one of those numbers and dials it, you want to display to the user-agent which of the Twilio numbers the customer is calling.
In the code above conn.parameters.To likely represents your default_client, if you specified one. But conn.parameters.From should actually display the number the caller is calling, which if I am understanding correctly is the desired behavior.
Hope this helps!

how to use OriginateAction class in asterisk java to originate a call to a PSTN number

I am new to asterisk, I am trying to originate a call from java application. I found OriginateAction is the class to originate a call to SIP or PSTN number, I tried to use this class but could not find any way how it helps me. Can any one suggest me how to use this class in order to meet my requirement.
I tried following
OriginateAction oa=new OriginateAction();
oa.setAccount(getName());
oa.setActionId(getName());
oa.setChannel("SIP/1000");
oa.setContext("default");
oa.setExten("120");
oa.setCallerId("2233");
the concept is that: You need to login via ami, then send the action, the minimum infomation you should send is channel(just the sip account like SIP/1000), context, extension, and priority, when you send the action, asterisk will try to call SIP/1000, if the peer answer the call the extension in the context will be called, the, you can do every thing.
maybe this will help I think:
asterisk manager dialout
, java example

Twilio - Get the most recent Conference call

I'm trying to find the fastest way to get a Conference Sid from an ended call's request. Since the Participant is removed from the Conference when the call ends, searching isn't possible (and not implemented in the PHP library anyways). I'm assuming the call left the most recent Conference, since its 'action' parameter is associated with its Dial into the Conference.
How do I get the most recent Conference using the PHP helper library?
Twilio evangelist here.
I don't think there is a way to just get the last conference directly from the API. What you can do is use the helper library to get a list of the conferences.
$client = new Services_Twilio('AC123', '123');
foreach ($client->account->conferences as $conference) {
print $conference->date_created;
}
When you do, each conference should include a DateCreated and a DateUpdated property that you can sort by to find the last one created or updated.
Hope that helps.

Resources