WaitExten during the call - asterisk

Scenario:
Asterisk receives incoming call to a DID number
Asterisk forwards incoming call to a mobile number using PSTN termination.
Call is answered on a mobile
Question:
Is there a possibility to transfer call to a different extension during the call ?

yes,but require guru level.
it can be done by writing special application or using conference or using AMI.
probably easy way is conference

Yes. This is very straight forward.
Presuming your DID is 1-234-567-8900 and your moble is 1-987-654-3210:
exten => _12345678900,1,NoOp(Call for DID to Mobile)
same => n, Dial(DAHDI/g1/19876543210,30,t)
same => n, HangUp()
The dial option "t" allows "...the called user to transfer the call by hitting the blind xfer keys (features.conf)"
Further reading: http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial

Related

Asterisk how check if a number is busy before dialing it

As a beginner that just installed his first asterix server I came across a small issue. i want to check if a number that i dial is busy or not before actually dialing it.
So for example I would call 0904 => number busy => redirect to 0905
However I don't want it to dial 0904 first if its busy but just instantly redirect it to 0905 instead.
I have a very basic setup with just 3 users. 2 of them are in a queue "support" one of them is in the queue "admin"
I have seen and read a little about checking if a channel is available but i didn't fully understand that and I'm not sure if it could be done easier.
Here is my simple dialplan, if i call *12 my simple python script will just execute the Dial command to the 0904.
exten => *12,1,Answer()
same => n,set(PHONE_EXTEN=0904)
same => n,AGI(test-agi.py,${PHONE_EXTEN})
same => n,Hangup()
There is no way know if external number is busy.
If number is your extension, you can count calls using GROUP/GROUP_COUNT or you can check extensions states and hints, like described in docs
https://wiki.asterisk.org/wiki/display/AST/Extension+State+and+Hints
https://wiki.asterisk.org/wiki/display/AST/Device+State

Asterisk run script on Phone Answer and Outgoing Call

I'm trying to make my Asterisk run a script whenever a certain phone (Sip Phone) answers or makes an outgoing call and when it ends that call. The purpose of that is to automatically mute my TV when a call is done with the phone in the same room.
I've tried using the System command but that doesn't get information about the phone that answered. As I am having multiple phones ringing, I can not distinguish if it was indeed the phone next to the TV or a completely different phone. Same problem I am having for outgoing calls.
Is there a different approach to this? I also tried using the AMI but I haven't found a way to get the status of a specific peer (Offline, Online, In Call, lagged).
Lets say you have ext sip/111
Support extension
[from-internal-very-special]
exten => 111,1,UserEvent(TVRingStarted)
same => n,Set(CHANNEL(hangup_handler_push)=from-internal-very-special,ends,1)
same => n,Dial(SIP/111,,U(from-internal-very-special,answer,1))
exten =>answer,1,UserEvent(TVRingAnswer)
same => n,Set(GOSUB_RESULT=);we accept call
same => n,Return;continue
exten => ends,1,Noop(end of call)
same => n,UserEvent(TVRingEnds)
same => n,Return;
After that call extension as Local/111#from-internal-very-special/n instead of SIP/111
You will have user events you can parse via AMI. Or you can replace that by System calls as you wish.

Out Bound Dialing Asterisk

I have a calling application developed in PHP with AGI on Asterisk framework, below is the basic flow of application.
We receive a call from user at our Asterisk ss7 server and forward the same call to another user from our server.
I want to know the status of call forward to another user. Status means what happen with call between both users e.g. Hangup, Busy, Not Answered etc.
Not much detail on how you are placing the call or anything else but if you are performing a Dial() and want to know at the end of the call the result try ${DIALSTATUS}.
This will contain something like 'ANSWER', 'NOANSWER' or 'BUSY'. For the full list and more info check out http://www.voip-info.org/wiki/view/Asterisk+variable+DIALSTATUS
you can use CDR feature or use a diaplan to get the dialed status
http://www.voip-info.org/wiki/view/Asterisk+variable+DIALSTATUS
http://www.voip-info.org/wiki/view/Asterisk+cdr+mysql

Asterisk ami/agi - not able to answer call

I have followed the instructions in this thread: Asterisk AMI - pickup call. However, I am still unable to answer calls via AMI. I can make the call to the extension, but corresponding phone for that extension doesn't ring. I can then run the AMI command to answer that call, it does answer, but obviously there isn't any actual response.
Dialplan (testing with extension 116):
exten => 116,1,AGI(agi:async)
Any ideas what I am doing wrong here?
Use
exten => 116,1,Answer
exten => 116,2,AGI(agi:async)
or use Answer action via ami.
http://www.voip-info.org/wiki/view/Asterisk+manager+API
You need listen event, when see agi-async event issue Answer on same channel. For example you can do playback command with answer.
Very likly you need start with AGI interface, which is much more simpler for understanding. Not use agi:async, it require understanding of asterisk internals.
Found the Answer. For those wanting to answer with API Manager you can use the following -
http://ip-address:port/asterisk/rawman?action=Originate&Channel=Local/(exten you want to answer with)#(context)&Application=Exec&Data=Pickup((exten you want to answer with)#PICKUPMARK)
I am of course using http to send my requests, if you are using something else you will need to change the format.
Or you can use the bridge command. Two channels will be created when you make a call from one extension to the other, bridge those channels and you will have better overall functionality than pickup.

Playing a music file before call connects using Asterisk

I have an asterisk server. I use the server to connect an incoming call to another extension based on a few key presses. There is a certain time lag (after the key/extension press and before the call connects). How can I play a small music file (of my choice) in this period? There are some constraints that come to my mind:
The music should play only as long as the call does not connect. So, the method used should be a non-locking one.
Any help on this is most welcome.
Thanks,
Sriram
Use the m flag to the Dial application, to play music on hold while the call is connecting.
exten => 9000,1,Noop
exten => 9000,n,Answer
exten => 9000,n,Dial(SIP/device,0,m)
I think Background is your friend (http://www.voip-info.org/wiki/view/Asterisk+cmd+BackGround)

Resources