Placing separate outgoing call from within dialplan

Hi FreePBX Community members,

With FreePBX Distro (SNG7-FPBX-64bit-1707-1), I’m building an IVR application where caller can call in and listen different categories of music. Everything seems fine for me with simple control logics in dialplan so far but one of the features of my application is allowing caller can send a music to their friend to listen to. I could gather a caller’s friend’s phone number and set it in variable of a context but I’m lost with how to tell Asterisk to place separate outgoing call to given SIP phone number from within an active incoming call and let the friend listen to the music dedicated. Because I’m new to IP PBX programming and, with Asterisk and FreePBX I seem have tones of documents and supports from the community, but by attempting to implement this feature for my application, it took me 3 days to research but no luck, that’s why I seek hints from the community. Please anybody give a clue to practically do this.

Many thanks in advance.
Nimeth

You want the Asterisk application ORIGiNATE.

Thank you for your response. I tried cmd Originate in my dialplan and it almost worked.

Here the line in my dialplan.
same => n(sendTheMusic),Originate(SIP/callcentric,exten,${FRIEND_NUMBER})

And I got this error from Asterisk logfile.
chan_sip.c: Received response: “Forbidden” from ‘“Anonymous” sip:[email protected]:5160;tag=as5a35ce72’

What does that mean and what should be done to have a successful call out?
Nimeth

Please anybody help me with problem placing a separate outbound call with ORIGINATE from an active channel within dialplan. I encounter problem of chan_sip.c: Received response: "Forbidden" from '"Anonymous" ;tag=as5a35ce72' and not sure how to fix this. Here is the cmd in my context same => n(sendTheMusic),Originate(SIP/callcentric,exten,${FRIEND_NUMBER})

Thanks in advance.
Nimeth

You are not using the Originate application properly.

Hi,

Thank you for letting me know that I didn’t use the cmd Originate correctly. I tried again as below line.

same => n(sendTheMusic),Originate(${CHANNEL},exten,send-music,${FRIEND_NUMBER},1)

With this line I go different error in the Asterisk logfile.

[2017-09-12 14:46:32] VERBOSE[180210][C-000000c3] pbx.c: Executing [1777xxxxxxx@9292-ivr:125] Originate(“SIP/callcentric1-000000c7”, “SIP/callcentric1-000000c7,exten,send-music,1777yyyyyyy,1”) in new stack
[2017-09-12 14:46:32] VERBOSE[180210][C-000000c3] netsock2.c: Using SIP RTP TOS bits 184
[2017-09-12 14:46:32] VERBOSE[180210][C-000000c3] netsock2.c: Using SIP RTP CoS mark 5
[2017-09-12 14:46:32] ERROR[180210][C-000000c3] netsock2.c: getaddrinfo(“callcentric1-000000c7”, “(null)”, …): Name or service not known
[2017-09-12 14:46:32] WARNING[180210][C-000000c3] chan_sip.c: No such host: callcentric1-000000c7

For testing purpose, the context is simple as below.

[send-music]
exten => s,1,Answer()
same => n, SayAlpha(Good afternoon)
same => n, SayDigits(123)
same => n, Hangup()

Could you please give me more hints or samples of correct use of the command?

Thanks in advance with egards,
Nimeth

Originate Command Description

Syntax

Originate(tech_data,type,arg1[,arg2[,arg3]])

Arguments

tech_data - Channel technology and data for creating the outbound channel. For example, SIP/1234.
type - This should be ‘app’ or ‘exten’, depending on whether the outbound channel should be connected to an application or extension.
arg1 - If the type is ‘app’, then this is the application name. If the type is ‘exten’, then this is the context that the channel will be sent to.
arg2 - If the type is ‘app’, then this is the data passed as arguments to the application. If the type is ‘exten’, then this is the extension that the channel will be sent to.
arg3 - If the type is ‘exten’, then this is the priority that the channel is sent to. If the type is ‘app’, then this parameter is ignored.

I’m still unsuccessful with placing outbound call using Originate in dialplan. I’m using SIP numbers from Callcentric. This is the command format I tried.

same => n(sendTheMusic),Originate(SIP/${FRIEND_NUMBER}@callcentric.com,exten,s@send-music)

And I have the lines below in log file.

[2017-09-13 06:17:59] VERBOSE[127877] dial.c: Called [email protected]
[2017-09-13 06:18:00] NOTICE[3987][C-000000c8] chan_sip.c: Failed to authenticate on INVITE to ‘“Anonymous” sip:[email protected]:5160;tag=as7ba347d8’
[2017-09-13 06:18:00] VERBOSE[127877] dial.c: SIP/callcentric.com-000000ce is circuit-busy

Could you correct me?

You don’t originate to ###@callcentric.com, you want to use the actual trunk name you have set up in FreePBX, something like SIP/callcentric/${FRIEND_NUMBER}. The actual trunk name you are using will be shown in ‘sip show peers’.

Thank you for providing alternative workaround to place an outbound call from active channel. On my asterisk server in development of an IVR application, I configured to test with Callcentric trunk name using FreePBX by following this guide on Callcentric. The sip show peers lists the following result:

Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1000 (Unspecified) D No No A 0 UNKNOWN
callcentric/1777MYCCID 204.11.192.163 Yes Yes 5080 Unmonitored
callcentric1/1777MYCCID 204.11.192.22 Yes Yes 5060 Unmonitored
callcentric10/1777MYCCID 204.11.192.135 Yes Yes 5060 Unmonitored
callcentric11/1777MYCCID 204.11.192.159 Yes Yes 5060 Unmonitored
callcentric12/1777MYCCID 204.11.192.160 Yes Yes 5060 Unmonitored
callcentric13/1777MYCCID 204.11.192.161 Yes Yes 5060 Unmonitored
callcentric14/1777MYCCID 204.11.192.162 Yes Yes 5060 Unmonitored
callcentric15/1777MYCCID 204.11.192.163 Yes Yes 5060 Unmonitored
callcentric16/1777MYCCID 204.11.192.164 Yes Yes 5060 Unmonitored
callcentric17/1777MYCCID 204.11.192.169 Yes Yes 5060 Unmonitored
callcentric18/1777MYCCID 204.11.192.170 Yes Yes 5060 Unmonitored
callcentric19/1777MYCCID 204.11.192.171 Yes Yes 5060 Unmonitored
callcentric2/1777MYCCID 204.11.192.23 Yes Yes 5060 Unmonitored
callcentric20/1777MYCCID 204.11.192.172 Yes Yes 5060 Unmonitored
callcentric3/1777MYCCID 204.11.192.31 Yes Yes 5060 Unmonitored
callcentric4/1777MYCCID 204.11.192.34 Yes Yes 5060 Unmonitored
callcentric5/1777MYCCID 204.11.192.35 Yes Yes 5060 Unmonitored
callcentric6/1777MYCCID 204.11.192.36 Yes Yes 5060 Unmonitored
callcentric7/1777MYCCID 204.11.192.37 Yes Yes 5060 Unmonitored
callcentric8/1777MYCCID 204.11.192.38 Yes Yes 5060 Unmonitored
callcentric9/1777MYCCID 204.11.192.39 Yes Yes 5060 Unmonitored
22 sip peers [Monitored: 0 online, 1 offline Unmonitored: 21 online, 0 offline]

And my Originate command looked like below

And still I get no luck, with following logged.
[2017-09-13 15:21:18] VERBOSE[8861][C-000000cd] pbx.c: Executing [17778960612@9292-ivr:125] Originate(“SIP/callcentric18-000000d6”, “SIP/callcentric/1777MYCCID/17778673755,exten,s@send-music”) in new stack
[2017-09-13 15:21:18] ERROR[8861][C-000000cd] netsock2.c: getaddrinfo(“17778673755”, “(null)”, …): Name or service not known
[2017-09-13 15:21:18] WARNING[8861][C-000000cd] acl.c: Unable to lookup ‘17778673755’
[2017-09-13 15:21:18] WARNING[8861][C-000000cd] chan_sip.c: Unable to locate host ‘17778673755’
[2017-09-13 15:21:18] VERBOSE[8861][C-000000cd] netsock2.c: Using SIP RTP TOS bits 184
[2017-09-13 15:21:18] VERBOSE[8861][C-000000cd] netsock2.c: Using SIP RTP CoS mark 5
[2017-09-13 15:21:18] WARNING[9021] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument
[2017-09-13 15:21:18] VERBOSE[9021] dial.c: Called callcentric/1777MYCCID/17778673755
[2017-09-13 15:21:18] WARNING[3987] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument
[2017-09-13 15:21:19] WARNING[3987] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument
[2017-09-13 15:21:21] WARNING[3987] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument
[2017-09-13 15:21:25] WARNING[3987] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument
[2017-09-13 15:21:33] WARNING[3987] chan_sip.c: sip_xmit of 0x7fc9fc0035c0 (len 865) to (null) returned -1: Invalid argument

Please tell me more.
Regards,