简体   繁体   中英

Create new channel in asterisk dialplan

This operation that I need to implement on Asterisk is similar to a call forwarding, but with some differences. This is a simplified explanation of the system.
There are three extensions: 100, 200 and 300. Calls between 100 and 200 are cheap, and calls from any extension to 300 are expensive. And extension 300 is programmed on the remote device to receive and accept calls only from extension 200.
Extension 200 program a "call forwarding" to extension 300 (it adds to a database).
When extension 100 calls extension 200, extension 200 should call extension 300 and transfer the call to extension 100.
The call forwarding examples I found suggest to use Dial() from the extension 100.

[context]
exten => s,1,Set(CFIM=${DB(CFIM/${ARG1})})
exten => s,n,GotoIf($["${CFIM}"!=""]?s-CFIM,1:s-NoCFIM,1)
exten => s,n,Hangup
exten => s-CFIM,1,Dial(Local/${CFIM},30,Ttr)
exten => s-CFIM,n,Hangup
exten => s-NoCFIM,1,Dial(${ARG1},30,Ttr)
exten => s-NoCFIM,n,Hangup

The problem with this approach is that the call to 300 is actually being made by extension 100 (the current channel). This will generate expensive billing for 100 and extension 300 will receive a call from 100, which it will drop.
What I need to do is create a new channel on behalf of extension 200, dial to 300 and then transfer that call to the current channel, so that extension 300 receives call from 200 and there are two billing generated: one from 100 to 200 and another from 200 to 300.
I tried using the Originate() app, but that doesn't work for me because it blocks until 200 picks up (which it will not do).
Any ideas on what I could do to solve this?

Use Local channels for that.

See freepbx.org system followme module for how realize followme with Local channel.

https://www.voip-info.org/wiki/view/Asterisk+local+channels

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM