How, run laravel commands, when calling, answer the call and end the call

hello all i have this problem when i call from 1002 to 1001 or vice versa i run laravel command to notify about the call and it works. When 1002 or 1001 answer the call, I want another command to be launched, but after the answer, other commands are not started, that is, they are executed until (same => n,Dial(SIP/1001,10)). But what’s interesting is when I don’t answer the call or answer the call, everything works, I mean after everything that is after (same => n,Dial(SIP/1001,10))

extensions.conf
[ext_1001]
exten => 1002,1,System(/usr/bin/php /var/www/serviceDesk.loc/artisan app:handle-call > /tmp/asterisk-script-output.log 2>&1)
same => n,Dial(SIP/1002,10)
same => n,NoOp(${DIALSTATUS}) ; Log the Dial status
same => n,Hangup()

[ext_1002]
exten => 1001,1,System(/usr/bin/php /var/www/serviceDesk.loc/artisan app:handle-call > /tmp/asterisk-script-output.log 2>&1)
same => n,Dial(SIP/1001,10)
same => n,NoOp(${DIALSTATUS}) ; Log the Dial status
same => n,Hangup()

logs when answered to call
Using SIP RTP CoS mark 5
– Executing [1001@ext_1002:1] System(“SIP/1002-00000002”, “/usr/bin/php /var/www/serviceDesk.loc/artisan app:handle-call > /tmp/asterisk-script-output.log 2>&1”) in new stack
– Executing [1001@ext_1002:2] Dial(“SIP/1002-00000002”, “SIP/1001,10”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/1001
– SIP/1001-00000003 is ringing
– SIP/1001-00000003 answered SIP/1002-00000002
– Channel SIP/1001-00000003 joined ‘simple_bridge’ basic-bridge
– Channel SIP/1002-00000002 joined ‘simple_bridge’ basic-bridge
– Channel SIP/1001-00000003 left ‘native_rtp’ basic-bridge
– Channel SIP/1002-00000002 left ‘native_rtp’ basic-bridge
== Spawn extension (ext_1002, 1001, 2) exited non-zero on ‘SIP/1002-00000002’

logs when not answered
Using SIP RTP CoS mark 5
– Executing [1001@ext_1002:1] System(“SIP/1002-00000000”, “/usr/bin/php /var/www/serviceDesk.loc/artisan app:handle-call > /tmp/asterisk-script-output.log 2>&1”) in new stack
– Executing [1001@ext_1002:2] Dial(“SIP/1002-00000000”, “SIP/1001,10”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/1001
– SIP/1001-00000001 is ringing
– Got SIP response 486 “Busy Here” back from 127.0.0.1:33087
– SIP/1001-00000001 is busy
== Everyone is busy/congested at this time (1:1/0/0)
– Executing [1001@ext_1002:3] NoOp(“SIP/1002-00000000”, “BUSY”) in new stack
– Executing [1001@ext_1002:4] Hangup(“SIP/1002-00000000”, “”) in new stack
== Spawn extension (ext_1002, 1001, 4) exited non-zero on ‘SIP/1002-00000000’

When call is answered extension h is called. You can put here your command

Other possibility is to use dial options like G or g

https://www.voip-info.org/asterisk-cmd-dial/

In your dialplan example, execution of the dialplan, is paused when the Dial() command is executing. Only whenever the call ends, will the Dial() command release control of the call, back to the dialplan.

What you want it to execute dialplan on one of the channels, whenever something happens during the dialing. For this you need to use the relevant parameters to Dial(). You can find them in the manual for Dial().

There are options for calling at different stages during the outgoing call from the top of my head you have the option of doing something at the following stages:

  • Right before sending the INVITE. (Or similar of not using SIP) Useful for things like setting caller ID etc.
  • After answer, but before bridging the channels

In both cases you can run dialplan on both channels, however, I have no clue which runs first, or if they run parallel to each other.

The h extension mentioned, is run on hangup, but only on the channel calling Dial().

To log a call, you would do your logging after Dial(), by checking the dialstatus. The dial status is stored in the channel variable DIALSTATUS, the possible values and their meaning, is described in the docs I linked previously.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.