0

I'm trying to get users to be able to record a message, hangup and have the call continue and dial Queues and playback the recording.

I've gotten most of the way there, but right now when I call Queue() in the h extension it hangs up immediately (the queue members do get the call for about 1ms). Although I am using option c

My dialplan (cut down for brevity)

[standard-gn-helpdesk-corona-afterhours]
; Hangup Extension
exten => h,1, NoOp(hangup standard-gn-helpdesk-corona-afterhours)
same => n, Gosub(sub-queue-gn-afterhours,s,1)
same => n, Return()

exten => s,1, NoOp(standard-gn-helpdesk-corona-afterhours)
same => n, Record(gn_ah_recording%d:ulaw)
same => n, Hangup()
; Callee has hungup by this point. `h` should be executed

[playback-recorded-message]
exten => s,1, NoOp(playback-recorded-message)
same => n, Playback(${RECORDED_FILE})

[sub-queue-gn-afterhours]
exten => s,1,NoOp(sub-queue-gn-afterhours)
; Has the `c` option which allows the queue to continue when callee hangs
same => n,Queue(GNAfterHours1,tkc,,,540,,,playback-recorded-message)
same => n,Return()

Any suggestions would be helpful. Will I be forced to use Dial() instead with the F option?

Mattisdada
  • 57
  • 2
  • 15

1 Answers1

0

I actually couldn't figure a way around all the issues encountered, my final solution ended up being a hacky workaround using AGI to initiate a new call using a local channel instead. My dial plan ended up looking something like this:

[standard-gn-helpdesk-corona-afterhours]
; Hangup Extension
exten => h,1, NoOp(hangup standard-gn-helpdesk-corona-afterhours)
same => n, AGI(dial-playback-recorded-messages.php)
same => n, Hangup()

exten => s,1, NoOp(standard-gn-helpdesk-corona-afterhours)
same => n, Record(gn_ah_recording%d:wav)
same => n, Hangup()
; Callee has hungup by this point. `h` should be executed

[playback-recorded-message]
exten => s,1, NoOp(playback-recorded-message)
same => n, Playback(${RECORDED_FILE})

[sub-queue-gn-afterhours]
exten => s,1,NoOp(sub-queue-gn-afterhours)
 ; Total hack! This is bad practice, but I don't have shared func and I couldn't find another way to keep this variable in scope when using Queue -> Sub
same => n, Set(GLOBAL(RECORDED_FILE)=${RECORDED_FILE})
same => n,Queue(GNAfterHours1,tk,,,540,,,playback-recorded-message)
same => n,Return()

[from-internal-default]
; Outbound dial for AH
exten => 8745111,1, Answer()
same => n, Gosub(sub-queue-gn-afterhours,s,1)
same => n, Hangup()

; Inbound dial for AH
exten => 8745112,1, Answer()
same => n, Wait(3600)
same => n, Hangup()

My AGI script looked like this (cut down for simplicity)

<?php
$recordingFile = $agi->get_variable("RECORDED_FILE", true);
$hasAh = (string) $agi->get_variable("HAS_AFTERHOURS", true); 

$originateMsg = new OriginateAction('local/8745112@from-internal-default');
$originateMsg->setContext('from-internal-default');
$originateMsg->setPriority('1');
$originateMsg->setExtension('8745111');
$originateMsg->setAsync(true);
$originateMsg->setTimeout(19000);
$originateMsg->setVariable('RECORDED_FILE', $recordingFile);
$originateMsg->setVariable('HAS_AFTERHOURS', $hasAh);
$response = $pamiClient->send($originateMsg);

How it works:

  1. Caller comes in and records a message
  2. Call hangs up and executes the AGI script which initiates a new call between a local channel of 8745112 and dialing local extension 8745111
  3. Extension 8745112 just waits to keep the connection open
  4. Channel 8745111 moves into a queue, once a call is connected it then runs the post queue sub playback-recorded-message which plays back a message

I'm confident there is a much better, less hacky solution, but with my level of understanding of Asterisk, this is the best I could come up with. Hope it helps someone

Mattisdada
  • 57
  • 2
  • 15