Playing custom audio on outbound calls and capturing DTMF (Press 1) to bridge to a local extension

Hi everyone,

I’m trying to set up a custom outbound dialing script using a .call file and Asterisk custom dialplan.

My Goal:

  1. Trigger an outbound call via a JMP SIP trunk to a mobile phone.
  2. When the person answers, play a custom audio recording cleanly right from the start (without clipping the first syllable).
  3. Allow the callee to press “1” during or after the message to bridge the call over to a local PJSIP extension (e.g., extension 100 running on MicroSIP).

What I’ve tried:

  • Using a standard Background() routine inside a subroutine: The audio plays, but the timing is sometimes out of sync or clips the beginning.
  • Using the A() dial option: Plays the announcement cleanly and instantly upon answer, but it’s a one-way stream and doesn’t allow capturing DTMF keypresses (like pressing “1”) to route the call back to my local extension.
  • Using the G() option to split the legs: Allows custom routing, but managing the split state between the callee leg playing the audio and capturing the extension input has been tricky.

Here is what my current custom extensions configuration looks like:

[outbound-trigger]
exten => _X.,1,NoOp(— Outbound Trigger Initiated —)
exten => _X.,n,Dial(PJSIP/${EXTEN}@Trunk,U(play-audio-sub))
exten => _X.,n,Hangup()

[play-audio-sub]
exten => s,1,NoOp(— Answer Confirmed: Interactive Prompt —)
exten => s,n,Answer()
exten => s,n,Wait(0.5)
exten => s,n,Background(custom/Request,m)
exten => s,n,WaitExten(10)
exten => s,n,Return()

exten => 1,1,NoOp(— User Pressed 1: Ringing MicroSIP —)
exten => 1,n,Dial(PJSIP/100,tT)
exten => 1,n,Return()

If anyone has a recommended best practice or example of how to cleanly play an announcement to an outbound callee and capture a DTMF digit to bridge them to an internal local extension, I would greatly appreciate the guidance!

Howdy! Welcome to the forums!

Regarding determination of when someone answers in order to avoid cutting off any audio playback, have you seen Asterisk’s Answering Machine Detection (AMD) dialplan app ?

Curious how that fares for you when combined with your existing BackGround dialplan app usage (including the m option for the single-digit shortcut, nice!)

Click here for slight digression on forum etiquette :-)

You might be interested in the Asterisk forums for dialplan-heavy posts as those are frequented by day-in-day-out readers and writers of extensions.conf files. Generally speaking, the FreePBX forums are for higher-level configuration questions, as the bulk of the Asterisk dialplan used by FreePBX is generated automatically by the FreePBX GUI.

Either way, for code snippets, it is a little easier for others to read if you select the text in question and click the </> icon at the top of the text editor

like
this

…or, manually add three backticks by themselves on the lines before and after the text in question.

@penguinpbx

This sounds suspiciously like scam call centres, and I would be hesitant to give this the time of day.