I am trying to develop a reminding system that will make an automatic call to remind a person of a specific event. For this I am using Asterisk to make the calls and PHP in order to create a call file for Asterisk. I want the call file to execute 30 seconds after it is added. To do this I set the modified time stamp in the PHP script. Everything works great except that I want to run a check agains a web service to determine if it is still relevant to call the user.
Here is my PHP script
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$request = json_decode(file_get_contents("php://input"));
$tmpcallfile = tempnam("/tmp", "call");
$callfile = tempnam("/var/spool/asterisk/outgoing/", "call");
$fh = fopen($tmpcallfile, "w");
fwrite($fh, "Channel: Local/9000@remind_event\n");
fwrite($fh, "CallerID: " . $request->{'FromPhoneNumber'} . "\n");
fwrite($fh, "MaxRetries: 3\n");
fwrite($fh, "RetryTime: 5\n");
fwrite($fh, "Context: remind_event\n");
fwrite($fh, "Extension: 9000\n");
fwrite($fh, "Priority: 1\n");
fwrite($fh, "Archive: Yes\n");
fwrite($fh, "SetVar: PHONE_NUMBER=" . $request->{'ToPhoneNumber'} . "\n");
fclose($fh);
touch($tmpcallfile, time()+30);
rename($tmpcallfile, $callfile);
}
?>
And my idea was to simply call the web service using curl in the extensions.conf however for this to be possible I need to be able to redirect the local call to an external call in case the web service tells that the call should be made. I have now made a simple extensions.conf just in order to transfer the internal call to an external number. I leave the curl check out for now.
The crazy thing is that I receive two different calls on my cell phone simultaneously when running the call-file and I am clueless of why. First I get one call, then there is a call waiting activated. When I pick upp I hear dial tone. If I park the first call and answer the second I hear silence. When I hang up the second call also the first call is hung up.
[voxbeam_outbound]
exten => _X.,1,NoOp()
same => n,Answer
same => n,Dial(SIP/voxbeam_outbound/${EXTEN})
[remind_event]
exten => 9000,1,NoOp()
same => n,Dial(SIP/voxbeam_outbound/${PHONE_NUMBER})
same => n,Playback(remind_event)
same => n,Hangup
For completeness here is also added lines in sip.conf although I guess these are actually not relevant:
[voxbeam_outbound]
type=peer
insecure=invite,port
nat=no
canreinvite=no
username=<hidden>
secret=<hidden>
host=<hidden>
context=voxbeam_outbound
Here is the output of asterisk -vvvr
Connected to Asterisk 13.16.0 currently running on sippoc2 (pid = 23986)
-- Attempting call on Local/9000@remind_event for 9000@remind_event:1 (Retry 1)
-- Called 9000@remind_event
-- Executing [9000@remind_event:1] NoOp("Local/9000@remind_event-00000000;2", "") in new stack
-- Executing [9000@remind_event:2] Dial("Local/9000@remind_event-00000000;2", "SIP/voxbeam_outbound/+467<hidden>") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/voxbeam_outbound/+467<hidden>
-- SIP/voxbeam_outbound-00000000 is making progress passing it to Local/9000@remind_event-00000000;2
-- Local/9000@remind_event-00000000;1 is making progress
-- SIP/voxbeam_outbound-00000000 requested media update control 26, passing it to Local/9000@remind_event-00000000;2
-- SIP/voxbeam_outbound-00000000 is ringing
-- Local/9000@remind_event-00000000;1 is ringing
-- SIP/voxbeam_outbound-00000000 requested media update control 26, passing it to Local/9000@remind_event-00000000;2
-- SIP/voxbeam_outbound-00000000 answered Local/9000@remind_event-00000000;2
-- Local/9000@remind_event-00000000;1 answered
-- Executing [9000@remind_event:1] NoOp("Local/9000@remind_event-00000000;1", "") in new stack
-- Executing [9000@remind_event:2] Dial("Local/9000@remind_event-00000000;1", "SIP/voxbeam_outbound/+467<hidden>") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/voxbeam_outbound/+467<hidden>
-- Channel SIP/voxbeam_outbound-00000000 joined 'simple_bridge' basic-bridge <94c7a115-a487-45ee-b516-2dd0f561b6fc>
-- Channel Local/9000@remind_event-00000000;2 joined 'simple_bridge' basic-bridge <94c7a115-a487-45ee-b516-2dd0f561b6fc>
-- Local/9000@remind_event-00000000;1 requested media update control 26, passing it to SIP/voxbeam_outbound-00000001
-- SIP/voxbeam_outbound-00000001 is making progress passing it to Local/9000@remind_event-00000000;1
-- SIP/voxbeam_outbound-00000001 requested media update control 26, passing it to Local/9000@remind_event-00000000;1
-- SIP/voxbeam_outbound-00000001 is ringing
-- Channel SIP/voxbeam_outbound-00000000 left 'simple_bridge' basic-bridge <94c7a115-a487-45ee-b516-2dd0f561b6fc>
-- Channel Local/9000@remind_event-00000000;2 left 'simple_bridge' basic-bridge <94c7a115-a487-45ee-b516-2dd0f561b6fc>
-- Local/9000@remind_event-00000000;1 requested media update control 26, passing it to SIP/voxbeam_outbound-00000001
== Spawn extension (remind_event, 9000, 2) exited non-zero on 'Local/9000@remind_event-00000000;2'
== Spawn extension (remind_event, 9000, 2) exited non-zero on 'Local/9000@remind_event-00000000;1'
[Aug 1 18:25:08] NOTICE[24053][C-00000001]: pbx_spool.c:460 attempt_thread: Call completed to Local/9000@remind_event