I use ARI to call 2 endpoints and Bridget them.
I want to hold or play media or play MOH call1 until endpoint2 answer call and then Bridget them.
I tried this plan but PlayBack, BackGround, MusicOnHold all of them block the thread until playing is finished and then call endpoint2.
exten => 107,1,NoOp()
same => n,Answer()
same => n,MusicOnHold(default,10)
#same => n,BackGround(silence/2&hello-world)
same => n,Dial(Local/***#from_internal_testing,U(default^postAnswer^1)) same => n,Hangup()
Are you really using ARI (i.e. Asterisk REST API)? I do not see that you are calling Stasis application from the dialplan. However, this operation should be invoked before you hand over the control over your channel to ARI.
All the methods mentioned above are suppored by ARI in the context “Channels”. The related specification is available here: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Channels+REST+API
What you trying to do do not require anything like that, just use app_queue
https://wiki.asterisk.org/wiki/display/AST/Building+Queues
If for some reason you still want do all that youself, you can use TIMEOUT(), dial via Local, conference etc.
Related
I want to hang the call just after answered.
exten => _3XXXXXXXXXX,1,Set(CALLERID(num)=1234567890)
same => n,MixMonitor(${UNIQUEID}.wav)
same => n,Dial(SIP/${EXTEN:1}#provider,,M(hang))
same => n,StopMixMonitor()
same => n,Hangup()
[macro-hang]
exten => s,1,Hangup()
any idea? I've tried a macro, but its not working.
From asterisk doc
M(macro[^arg[^...]]):
macro - Name of the macro that should be executed.
arg - Macro arguments
Execute the specified <macro> for the *called* channel before connecting to the
calling channel. Arguments can be specified to the Macro using '^' as a
delimiter. The macro can set the variable ${MACRO_RESULT} to specify the
following actions after the macro is finished executing:
${MACRO_RESULT}: If set, this action will be taken after the macro
finished executing.
ABORT: Hangup both legs of the call
CONGESTION: Behave as if line congestion was encountered
BUSY: Behave as if a busy signal was encountered
CONTINUE: Hangup the called party and allow the calling party to
continue dialplan execution at the next priority
GOTO:[[<context>^]<exten>^]<priority>: Transfer the call to the
specified destination.
Both ABORT and CONTINUE should do what you want.
Use Dial's L option. This way you can adjust the length of the call. From https://www.voip-info.org/asterisk-cmd-dial :
L(x[:y][:z]): Limit the call to ‘x’ ms, warning when ‘y’ ms are left, repeated every ‘z’ ms).
Note: If you will make the calls to a SIP provider, they will round up the up time (if you set L(1), even if it is 1 ms it will count as 1 second). Also, they will most likely suspend your account for wangiri fraud.
Hello guys,
I would like help to setting up my dial plan to execute more than one application at a time. In the example below I created 3 contexts, where the call made by the anlz01 context makes a dial to the anlz02 context and makes a subroutine for the anlz03 context.
The following example context:
context anlz01 {
_X. => {
Dial(local/200#anlz03,30,CU(anlz02,s,1));
}
}
context anlz02 {
200 => {
Playback(gravacoes/21971192789-20170103-143043-P1C55-E1, noanswer);
}
}
context anlz03 {
s => {
Wait(3);
Progress();
Wait(5);
Hangup();
}
}
My goal is that while the playback is running the other applications of the anlz03 context also has be executed. How could I achieve this goal?
It is not fully clear what exactly you need.
Asterisk dialplan allow execute ONE application stream.
If you need same time playback something, create other channel set using asterisk dialout, after that use ChanSpy app to wisper that to first channel.
https://www.voip-info.org/wiki/view/Asterisk+auto-dial+out
https://www.voip-info.org/wiki/view/Asterisk+cmd+ChanSpy
If you need execution of some complex math, use FastAGI and your favorite language with Threads.
You also have option supply hold music to be played while you are dialling. See application Dial parameters.
so i need to use a variable from a context that a caller called to the context that the called party uses, so i have a code like this
[calledContext]
exten => s,1,goto(waits)
same => n,goto(playmessage)
same => n(waits),set(a=0)
same => n(waits2),wait(5)
same => n,GotoIf($[${a} = 0]?waits2:hang)
same => n(playmessage),noop(${randomId})
same => n(hang),hangup();
[callerContext]
exten => 012345,1,Noop()
same => n,set(randomId=523)
same => n,Dial(SIP/09201234567,20,G(calledContext^s^1)g)
same => n,hangup()
heres my problem, in the calledContext context, when i use noop() on ${randomId}, nothing is displayed, how do i pass the value of the randomId from callerContext to calledContext?
SHARED is not what you want here.
The G option in Dial is one of those fun options that sends the two channels involved in the Dial operation to different places. Both are going to be sent to the Context/Extension you specified, which - given the names of the contexts - is probably not what you want. The called party gets sent to priority+1; the calling party priority.
That is, I'd expect the called party to start executing at calledContext,s,2 and the calling party to start executing at calledContext,s,1. But that's ancillary to your issue.
A variable set on an inbound channel can be passed to the channels it dials using channel variable inheritance. That is:
exten => 012345,1,Noop()
; Using a single underbar will set randomId on all channels this
; channel creates, but will not continue to propagate further
same => n,set(_randomId=523)
; Using two underbars will cause the variable to always propagate
same => n,set(__someOtherId=111)
same => n,Dial(SIP/09201234567,20,G(calledContext^s^1)g)
same => n,hangup()
Using the _ or __ will cause the variables to be set on the called party. If you want the variables to continue to propagate to channels the called party may also call, then use __.
Asterisk use concepts of CHANNEL or leg.
So in your call you have 2 channel, each one have independent variables and control structure
You can see name of bridged channels by BRIDGEPEER
http://www.voip-info.org/wiki/view/Asterisk+Detailed+Variable+List
You can get variables of other channel by using function SHARED maybe.
http://www.voip-info.org/wiki/view/Asterisk+func+shared
For see variables set in current channel you can use application DumpChan
Can I create a new conference room (Asterisk ConfBridge) through Asterisk Manager Interface (AMI)? Help me please!
This response is for anyone who has struggled as me to do this, even if the first response and the comments to it may be enough.
So, you can originate a conference call, with the action Originate and the application ConfBridge (as far as i know, it comes with Asterisk, not independent).
You can see all the available fields here http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate
I will throw an example without every field, but the ones I know and needed on my app.
This is what you throw at the Asterisk Manager Interface, if you want to call someone into a conference, then add someone else (without the comments ofc.)
Action: Originate // The action type
ActionID: CreateConf-1 // This id will be linked to further events about the action
Channel: SIP/1001 // The sipId of the peer u wanna call
Timeout: 30000 // If he doesnt respons in 30000ms, drop it
CallerID: Asterisk // The id of the caller (will be seen on target phone)
Application: ConfBridge // The application
Async: true // (NOT SURE, MAYBE BULLSHIT) If false, i think you can no longer originate while he hasn't answered
Data: 1234 // Very important, this is like the conference id, will detail above
Action: Originate
ActionID: CreateConf
Channel: SIP/1000
Timeout: 30000
CallerID: Asterisk
Application: ConfBridge
Async: true
Data: 1234
So with this, one block at time, two guys will be called into a conference.
As you saw the Data field represents the identifier of the call, so if you wanna give your conference an id, use it. This way you could create and manage different conferences.
Since i work with NAMI (the nodejs library for Asterisk Manager Interface) (https://github.com/marcelog/Nami), let me also drop you how to do thanks to the lib.
var namiLib = require('nami');
var namiInstance = new (namiLib.Nami)(config); // See more about config (and everything else about nami) in their docs
namiInstance.open();
var action = new namiLib.Actions.Originate();
action.channel = 'SIP/1000';
action.data = '12345'; // my conferenceId
action.timeout = 30000;
action.callerID = 'Metisse\'s king';
action.application = 'ConfBridge';
action.async = true;
namiInstance.send(action, function (response) {
// deal with the response
});
Obviously, if you need to use NAMI to have control other Asterisk, you have to do something more generic to handle sending your actions and validating them, also watching for errors.
You can use dynamic conference(without room exist) feature and create calls using Originate command to application Confbridge.
No. You can use an AMI redirect to transfer your call to a piece of dialplan code that would read a channel variable, database look up or some other mechanism to set up a new conference, however.
For a full list of AMI actions for ConfBridge, please see: https://wiki.asterisk.org/wiki/display/AST/ConfBridge+10#ConfBridge10-ConfBridgeAsteriskManagerInterface(AMI)Actions
I am writing a dialplan in Asterisk where I am required to implement a bookmarking feature. If a user calls in and the call gets disconnected, on redial the user must be taken to the exact same clip on which the call was dropped or disconnected last. The dialplan (with bookmarking feature) currently looks something like so:
[some-context]
exten => 0,n,System(progressmarker.sh ${CALLERID(num)} ${CONTEXT})
exten => 0,1,Background(wav1)
exten => 0,n,Background(wav2)
There are hundreds of such commands. progressmarker takes the context and puts it into a file. When the user wants to continue the old session, it starts from the last context the user was in. If the call gets dropped after wav1 or wav2, the user should start from wav1 or wav2 and not from the last context.
There is one way of doing this:
exten => 0,n(wav1),Background(wav1)&System(progressmarker.sh ${CALLERID(num)} ${CONTEXT} wav1)
But you can see this way is inelegant and cumbersome especially since there are hundreds of such commands. Is there a better way of implementing the bookmarking feature?
One way to do this is to employ the h extension. This is the extension that gets called when the channel encounters a hangup. The solution would look like so:
Keep saving the priority in a global variable.
Implement the hangup extension for each context. The channel variables such as last context, extension and priority are all accessible (contrary to what the documentation says). The extension will look something like so:
exten => h,1,System(<Execute a script here that saves the last context, extension and priority to a file that can be read later and control returned here.>)