I have a working Asterisk 13 Dialplan where a call goes into extensions.conf and then within extensions.conf into a switch statement:
switch => Realtime
That works. The call completes based on the content of the database table.
Now what I want to do is a little filtering before the call goes to the Realtime table. Something like this:
exten => _X.,1,Set(GROUP()=${ACCOUNTCODE:0:4})
exten => _X.,n,GotoIf($[${GROUP_COUNT(ABCD)} > 2]?tooMany,1)
exten => _X.,n,Log(VERBOSE,Call Continuing. ${ACCOUNTCODE} is not a limited group)
switch => Realtime
exten => tooMany,1,Congestion(4)
exten => tooMany,n,hangup(503)
BUT, what seems to happen is that once the extension matches (the _X.) the processing continues through the match but does not continue and process the "switch => Realtime" line (it never executes the database component of the dialplan)
How do I get the Realtime dialplan to execute after going through the filter?
Second somewhat related question
Incidentally, I can have a similar problem in an all-text extensions.conf where I want all calls to have something done to them, and then do something specific to certain calls. e.g.
exten => _X.,1,<do something>
exten => 1122,1,<do some more stuff to the same call>
This is treated in the documentation and 1122 is the more specific line and will be the one executed. BUT, what is the correct way of doing something to all calls AND then do the specific thing?
I think you not understand how switch Realtime works.
It is not possible do switch for one extensions(or pattern) only. It is possible do for CONTEXT. When asterisk engine see switch=>realtime it works like include, i.e include database search in this WHOLE context.
You also seams like not understanding how dialplan works(otherwise will be no question 2). Please read book like ORelly's "Asterisk the future of telephony", it have step-by-step description of how that works.
Related
I have a Sagoma 8 port card with PRI PSTN DAHDI lines.To manage the traffic I am trying to use the group function to get the statistics. Below is the code
same => n,Set(Group=g1)
same => n,Set(GCOUNT=${GROUP_MATCH_COUNT(${GROUP})})
same => n,NoOp(---Count--${GROUP}---${GCOUNT}---${GROUP_LIST()}----)
Which prints
---Count--g1---0-------
But there is traffic on that DID, similarly I tried other functions like GROUP(),GROUP_LIST() that also dint work.
Is there anything I am doing wrong?
core show functions display then method definition means it is compatible the why I am not able to use it?
You are using asterisk functions incorrect, as varables. You should use it as functions
exten =>s,1,Set(GROUP(class)=item);
exten =>s,n,Noop(${GROUP_COUNT(item#class)})
If you not want class, you still should use function(it case sensitive and have "()"):
exten =>s,1,Set(GROUP()=item);
exten =>s,n,Noop(${GROUP_COUNT(item)})
That is actually item#default.
Please help in the problem that I encountered recently.
When implementing the function of informing the caller "User talking on the first line Please wait or call back later." With the function "Call Waiting" in the Asterisk I use this macro:
extensions_custom.conf
[from-internal-custom]
exten => _XXX,1,Macro(check-number,${EXTEN})
include => macro-check-number
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
ml - filename for playback
And this feature works!
But the macro works for the entire Asterisk, this queue calls, group calls - and that is the problem.
I have an idea - a group of calls and queue calls to assign numbers four-digit extensions, for example: 2222 - but are not you should not be, it is a false solution to the problem, because of which in the future could be a problem!
Maybe somebody faced a similar problem?
You don't need to include section in the from-internal-custom context
as extensions_custom.conf file is included in the dial plan.
You need to change the pattern of extension:
[from-internal-custom]
exten => _99XXX,1,Macro(check-number,${EXTEN:2})
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
You have analyze environment of call based on your dialplan.
For examples of such dialplan you can see recoring macro in freepbx project. However simplest way is just use different context for ringgroup/queues and direct diallling.
The problem was solved in the circuit.
Since we serve telephony server with no more than 250 members - it was decided to create a four-digit number for the groups and queues.
I am using asterisk.I have DID in which 4 numbers are mapped(stored in my database) so when user calls to that DID number the call is forwarded to the any one number mapped on that did.
My problem is that when user calls to DID the one of the four executive receive calls from the DID number not with user number .This is my part of dialplan code the call is routed from another context(not given below) to the direct context
[direct]
exten => start,1,noop(######START######)
same => n,mysql(Query resultid ${connid} SELECT number from database);;;DDDDDD
same => n,MYSQL(Fetch fetchid ${resultid} number )
same => n,mysql(clear ${resultid})
same => n,set(__NUMBER=${number})
same => n,dial(DAHDI/g0/0${NUMBER},20,mM(ANSWEREDED))
[macro-ANSWEREDED]
exten => s,1,noop(CALL_ANSWERED)
exten => s,n,Mixmonitor(/recordings/record.wav)
How can i change the number that flashes on executive number(number mapped on DID) to the caller number?
Thanks in advance.
1) Every asterisk book have example. Doing asterisk coding without reading book - not so nice idea
2) callerid can be set like this
same => n,set(__NUMBER=${number})
same => n,set(CALLERID(num)=123445678)
same => n,dial(DAHDI/g0/0${NUMBER},20,mM(ANSWEREDED))
3) If you use pstn dahdi connection(FXO card), that will not work. If you use digital connection, it can work if provider support that.
4) Use of app_mysql is depricated. Use func_odbc or realtime.
5) Use of mixmonitor inside on-call macro is extremly bad practice. Use mixmonitor with 'b' option before call out.
I'm wondering how I should go about running some applications in the current context, and then switching to another context (as if it had been included).
So, for example, I have several contexts for incoming calls but, for one in particular, I need to perform some extra actions (specifically, I need to Answer() it and delay it for a second). So, suppose that I had something like this:
[main-context]
include => this
include => that
[special-context]
exten => s,1,Agi(agi://<whatever>}
exten => _X.,1,Answer()
same => n,Wait(1)
include => main-context
What I'd like is for calls coming in to special-context to get Answer()ed and then main-context included, as if the extension hadn't been matched in special-context.
(I am already using the s-extension, as shown, but that seems to run in parallel to the normal execution of the extension anyway, so I don't think that would help.)
Is this possible?
You can use goto command.
[special-context]
exten => _X.,1,Answer()
exten => _X.,2,Goto(main-context,${EXTEN},1)
P.S. I higly recommend you read any single asterisk book, for example ORelly's "Asterisk the future of telephony"
Another solution:
[special-context]
exten => s,1,Agi(agi://<whatever>}
exten => _X.,1,Answer()
same => n,Wait(1)
same => n,Dial(Local/${EXTEN}#main-context)
According to the manual, this calls a pseudo-channel (chan_local), which places a call back in to the dialplan.
I'm starting up an AGI interface (in the s-extension) as well, and it should be noted that the extra Dial() interferes with the signalling that you receive on the AGI interface. For me, the solution posted by arheops worked much better.
I'm trying to solve a very painful problem that impedes on my world utilizing my amazing powers as a programmer... (my front gate makes my friends call my cell phone, then I have to press "9" and it lets them in)...
So, my amazing powers have gotten me very far, except this last part I can't get (perhaps due to lack of sleep).
I've got every thing worked out so far: The call-box now dials my Google Voice account, which forwards it to my virtual machine on my laptop running the latest 'trixbox' (Asterisk), which will receives the call via Gizmo5/SIP junk.
What I need now is to have the phone call answered, and then "press" the number "9"... wait about 5 seconds, then hang-up.
I'm sure it's as easy as putting this code somewhere in a config file:
exten => 1234,1,Answer
exten => 1234,n,Press("the flippin 9 key")
exten => 1234,n,Wait(5)
exten => 1234,n,Hangup
But I don't know:
1) Is this possible (pretty sure it is)
2) What file do I edit?
3) Do I need to make an extension first?
4) Is that code in my example above anywhere close?
5) What do I actually need to do!
I greatly appreciate any help on this one.
You're close, try:
exten => 1234,1,Answer
exten => 1234,2,Wait(2) ; Safety time
exten => 1234,3,SendDTMF(9)
exten => 1234,4,Wait(5)
exten => 1234,5,Hangup
This tells Asterisk how to handle a call coming in for 1234
In a "standard" Asterisk installation, this goes in extensions.conf and 1234 should be whatever extension/number the incoming call is coming in on.
extensions.conf has different sections, which can vary based on distribution and local setup, but it's usually best to put this in the [default] section.