Changing the caller number in an incoming call in asterisk - asterisk

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.

Related

Asterisk Freepbx - hide external number on user's display after forwarding

For some reason I can not find the necessary information on the Internet.
Subscriber A has set forwarding to an external number (output to the city goes through a sip trunk). I want this external number to be hidden for subscriber B, when he calls subscriber A.
How to implement?
Those. In my understanding there should be a condition:
If the call was forwarded and a call was made to a number that starts with _11X (exit to the city) Then perform the callerid replacement function.
####################################################################
Update:
Perhaps I explained incorrectly.
For example, I call from number 2222 to number 3333 (these numbers are located on Asterisk). Call forwarding to mobile number 11444555566 is set on number 3333 (Calls to external numbers go through sip trunk to siemens)
So, when I call like this, I see that the call goes to number 3333, but when the mobile number 11444555566 answers, then I see this number 11444555566 on the my phone, but I would not want it to be visible on the display, because we consider mobile number information to be private.
And I would like to hide this number only if forwarding to numbers _11 is set
On FreePBX, I can make a custom dialplan in extensions_custom.conf, but I need a hint.
for example, I now have a simple dialplan for external outgoing calls in extensions_custom, i want to hide ${EXTEN} on the phone display:
[dial-siemens]
exten => _11.,1,Set(CALLERID(num)=${CALLERID(num)})
exten => _11.,n,Dial(PJSIP/${EXTEN}#Siemens,120)
exten => _11.,n,Hangup()
####################################################################
UPDATE:
I continued to look for a solution and something worked, but not completely.
It turned out to remove the number from the phone display with such a dialplan setting, the I option helped.
exten => _11X.,1,Set(CONNECTEDLINE(num)=fwd to external)
exten => _11X.,n,Dial(PJSIP/${EXTEN}#Siemens,,I)
exten => _11X.,n,Hangup()
Now, when dialing an external number _11, I see "fwd to external" instead of the number. This is what I need.
Now I need to make the rule only run when the call has been redirected. Need help.
There is no need in do anything like that.
If you have DID forwarded to asterisk PBX and customer A call to that did - there is no any way for customer know where call was send. External number, sip device, artifact intelligence system, conference etc - all will looks the same. Customer should know only DID's number.
If you need customer B not know callerid of customer A, you just should replace CALLERID on the router you are using to call B. I.e put one of your did in CALLERID field at outbound routes and select "force callerid".
Hint: You can have multiple outbound rules per trunk, with different prefixes.
it seems to work like that:
[dial-siemens]
exten => _11X.,1,ExecIf($["${DB(CF/${CONNECTEDLINE(num)})}"!=""]?Macro(dial-siemens-cf-external,${EXTEN}),s,1)
exten => _11X.,n,Dial(PJSIP/${EXTEN}#Siemens,120)
exten => _11X.,n,Hangup()
[macro-dial-siemens-cf-external]
exten => s,1,Set(CONNECTEDLINE(num)=fwd to external)
exten => s,n,Dial(PJSIP/${ARG1}#Siemens,,I)
exten => s,n,Hangup()

Asterisk - Make a call inside a conference with ringtone

I'm trying to make a call inside a running conference and hear the ringtone.
*Note: the conference is already running I have only the admin inside.
I already tried different approaches to make the call without success
1) Originate:
channel originate SIP/000000000#provider application ConfBridge ConferenceName
This works, makes the call and when its answered it joins the conference, but no ringtone
2) ConfBridge Menu, dialplan_exec
[default_menu]
type=menu
1=dialplan_exec(addcaller,000000000,1)
[addcaller]
exten => _XXXXXXXXXX,1,Originate(SIP/${EXTEN}#provider,app,ConfBridge,ConferenceName)
This works, makes the call I have ringtone, but when answer, no audio inside conference
3) Options 2 + a macro to join call after answer
same => n,Dial(SIP/${EXTEN}#provider,,M(joinconf))
[macro-joinconf]
exten => s,1,NoOp()
same => n,ConfBridge(ConferenceName)
same => n,Hangup()
This works, I can hear the ringtone and then I can see the user inside the conference but again, no audio!
4) All versions with variants
I have tryied all sort of variants using
same => n,Answer()
same => n,Progress()
same => n,Wait(1)
cause maybe was the channel not answered, but I'm stuck.
the final goal is a simple
conference with the power of calling and hanging other phones.
No matter if I need to use:
AMI with multiple commands
channelredirect
chanspy
meetme
AGI
whatever just need to make it work
Do originate into Local channel, in dialplan use Ringing(r param in dial command) or moh with ringing sound

Continue Asterisk Dial Plan after Wild Card Match

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.

Not able to connect incoming caller to th dialed calee in meetme function in asterisk

My code is simple A calls to B the they both entered into meetme conference
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mM(MYCONFO))
[macro-MYCONFO]
exten => s,n,Meetme(1234,sdrM)
But when A calls to B only B enters the conference and A is not able to enter conference , A only hears musiconhold
yes i have read meetme and n way dialout
Can anybody help me with that
I think for this you should use option G from DIAL command:
http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial
G(context^exten^pri): If the call is answered, transfer both parties to the specified context and extension. The calling party is transferred to priority x, and the called party to priority x+1. This allows the dialplan to distinguish between the calling and called legs of the call (new in v1.2). You cannot use any options that would affect the post-answer state if this option is used.
So dialplan should be:
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mG(MYCONFO,s,1))
[MYCONFO]
exten => s,1,Meetme(1234,sdrM)
exten => s,2,Meetme(1234,sdr)
You code is incorrect.
Please read again documentation about in-call-macro. It have alot of limits
Try use goto.
If not work, try use transfer from external application with UserEvent
ps. yes, it work as described in n-way-howto too.

Can I match in a context and then include other contexts in an asterisk dialplan?

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.

Resources