Hook Flash transfers with a SIP ATA

I thought I’d write some notes on how to transfer calls or otherwise interact with a flash event, as there is only obsolete or incomplete information online on doing this.

For this I’m using a Grandstream 802, with a manual (no dial or touchtone) phone. The drive to do this was flash events was basically the only thing I could act on in my situation. I’m running FreePBX and Asterisk 20 on a Raspberry Pi. I think these steps will also work on Asterisk 18 and 19 as well.

So to do this, first I configured to send the flash event instead of processing it locally. The setting for this device was setting “Send Hook Flash Event” to Yes.

Next, I created a AMI application that listens for flash events, and forward both ends of a call when a flash is received.

I did this in Javascript (Node.js), using this library:

Here’s my code:

  * This redirects a call in response to a flash event
  * in redirects the caller to ext 23, and the callee to ext 25
var ami = require('asterisk-manager')('5038','localhost','ami-user','xxxxxx', true);

// this will attempt to reconnect every 10 seonds if there's a disconnect

ami.on('flash', function(evt) {
   // Grab the other side of the connection
      'action': 'command',
      'command': 'core show channels concise'
   }, function(err, res) {
      if (err) {
      var caller = res.output.find(element => element.endsWith(evt.linkedid));
      caller = caller.substring(0, caller.indexOf('!'));
      // transfer both sides of the call
         'action': 'redirect',
         'channel': caller,
         'exten': 23,
         'priority': 1,
         'extraChannel': evt.channel,
         'extraContext': 'from-internal',
         'extraExten': 25,
         'extraPriority': 1

// Display all responses (for debugging)
ami.on('response', function(evt) {

This thread is what I found on the subject which is obsolete.

Sorry for not updating that thread… I’m actually the one that added the Flash AMI event to Asterisk. At the time, it wasn’t possible to do that, so the information there was correct at the time. Glad you’ve also found it useful! My original use case was basically something like that.


Thanks for your change. I’ve got a little pbx to demo some old phones, and it is nice to have the option to do something on a flash event.

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