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

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

Related

problem make token bsc (Low level interactions)

i make token in remix.eth but get error , Low level interactions
( Both 'receive' and 'fallback' functions are not defined)
please help me
thanks
In the "Deploy & Run Transactions" tab, there's a selectbox allowing you to chose which of the contracts you want to deploy as the main contract. It's sorted alphabetically, so the Address (one of the contracts listed in the linked .sol file) comes as the first and default option.
You most likely wanted to deploy the COMF contract instead.
The Address contract is a helper library. It doesn't have any public and external functions, so the list of available functions to call is empty.
It also doesn't have the receive() and fallback() functions, so the low-level call with empty payload fails with the "Both 'receive' and 'fallback' functions are not defined" message.

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: Making conference name dynamic with REST apis

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')

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!

Broadcasting to a subset of subscribers in Atmosphere

What I'm trying to do:
Be able to have users subscribed to a number of different 'chat rooms' and use reverse AJAX / comet to send messages from a chat room to everyone logged into that room. (a bit more complicated but this is a similar use case).
What I'm doing:
Using Grails with JMS and Atmosphere. When a message is sent, I'm using JMS to send the message object which is received by a Grails service which is then broadcasted to the atmosphere URL (i.e. atmosphere/messages).
Obviously JMS is a bit redundant there but I though I could use it to help me filter who should retrieve the message although that doesn't really look it'll work (given that the subscriber is basically a singleton service...).
Anyway, what I need to be able to do is only send out a message to the correct subset of people listening to atmosphere/messages. A RESTful-type URL will be perfect here (i.e. atmosphere/messages/* where * is the room ID) however I have no idea how to do that with Atmosphere.
Any ideas / suggestions on how I can achieve what I want? Nothing is concrete at all here so feel free to suggest almost anything. I've even been thinking (based on the response to another question), for example, if I could do something like send out messages to a Node.js server and have that handle the reverse AJAX / comet part.
If I understand your requirements correctly the following should work (jax-rs + scala code):
1) Everyone who wants to get messages from a chat room registers for it:
#GET
#Path(choose/a/path)
def register(#QueryParam("chatroomId") chatroomId: Broadcaster) {
// alternatively, the Suspend annotation can be used
new SuspendResponse.SuspendResponseBuilder[String]()
.resumeOnBroadcast(false).broadcaster(chatroomId).scope(SCOPE.REQUEST)
.period(suspendTimeout, TimeUnit.MINUTES)
.addListener(new AtmosphereEventsLogger()).build
}
2) To broadcast a message for all the registered users, call the following method:
#POST
#Broadcast
#Path(choose/a/path/{chatroomId})
def broadcast(#PathParam("chatroomId") id: String) {
// first find your broadcaster with the BroadcasterFactory
BroadcasterFactory.getDefault().lookupAll() // or maybe there is a find by id?
broadcaster = ...
broadcaster.broadcast(<your message>)
}
I also recommend reading the atmosphere whitepaper, have a look at the mailing list and at Jeanfrancois Arcand's blog.
Hope that helps.
There is a misunderstaning of the concept of comet. Its just another publish/subscribe implementation. If you have multiple chat-rooms, then you need to have multiple "topics", i.e. multiple channels the user can register to. E.g.:
broadcaster['/atmosphere/chatRoom1'].broadcast('Hello world!')
broadcaster['/atmosphere/chatRoom2'].broadcast('Hello world!')
So I would advance you to creaet multiple channels and do not filter manually the set of users, which should retrieve messages (which is definitely not the way it should be done). You do not need to create anything on the server side on this, since the user will just register for a specific channel and receive messages, which anyone is putting into it.
I would recommend you create an AtmosphereHandler for one URL like /atmosphere/chat-room and then use the AtmosphereResource and bind an BroadcastFilter with it, lets say name it ChatRoomBroadcastFilter.
Whenever a user subscribes to a new chat room, a message would be sent to the server (from the client) telling the server about the subscription. Once subscribed, maintain the list of users <> chat room bindings somewhere on the server.
Whenever a message is broadcasted, broadcast it with the chat room id with it. The in the ChatRoomBroadcastFilter (You probably need to make this a PerRequestBroacastFilter) propagate the message to the user only if the user subscribed to the chat room. I am not sure if this clears it out. If you need code example please mention in the comments. I'll put that but that needs some time so ain't putting it right now ;).

Resources