Question

I've got Asterisk 11.4.0, a remote cloud server and a Node.js server as middleware. When any account tries to make a call, I need information from remote server which external line to use (or even not make this call at all!). Those data can't be calculated directly in Asterisk. Only after cloud's response the call must be proceeded. My action queue looks like this:

Capture the call initiation from Asterisk with AMI on middle server;

Send info to cloud for analysis;

Proceed a call with passed in response external line using AMI (or not proceed at all);

The problem is, I don't know how to make it. I think, when one tries to make a call, I can use WaitExten in dialplan option and capture Newchannel event with middle server, sending all information to cloud. When it responses, I can originate the call, using existing waiting line.

Can you tell me, how can I attach channel to Originate operation, when i pass it as "channel" parameter, Asterisk do not connect this line with called exten.

Was it helpful?

Solution

You need use FastAGI or AGI(fastagi faster but slighly more complex) to control call flow of your channel.

http://www.voip-info.org/wiki/view/Asterisk+FastAGI

In AGI you can get call info, decide where to place it, after that make call using Dial command. Calls will be bridged automaticaly.

http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial

Also you can use Bridge ami action to bridge 2 channels, but that is not how it have be created. Correct way - via Dial.

http://www.voip-info.org/wiki/view/Asterisk+cmd+Bridge

Also you can use in dialplan CURL function to request help via http on external API. That will have same cost as fastagi, but can be simpler for your since you like node.js

If you use Originate ami command, you can add to that command any variables via

 "Set" =>  "variablename=somethign"

PS actually almost anything can be calculated inside asterisk, sure if you have enought knowledge about that. Asterisk have full language(mean you can describe any algorithm in dialplan), have function to request db info etc.

DISCLAIMER: I recommend read asterisk book like "Asterisk the future of telephony" BEFORE creating any design of application with use of asterisk pbx. If you ignore this warning, your app can be unstable and require full rewrite after you put it in production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top