Run Script Directly After Dial Command Before Answer

Is there is a way to immediately run a script/subroutine/macro right after the dial command? My goal is to send the channel that the call is being placed on down to the mobile phone where the call is headed to alert the on phone app about call information.

There may be a better way to do this, the other option is perhaps I can match the call by caller id, so the other way to look at this is there a way to get a list of caller ids for all active channels?

This is all happening in a SIP environment. Thanks!


Let me start by saying I’m not sure I fully understand your question. If you’re asking about executing a command upon call answer, there are the M and U options to the Dial command. Or, if I understand your goal correctly, you could simply do this before the dial command.

I recommend you the use of AMI, with AMI you can monitor all calls and do specific things, like open web browser & pop up window with the caller information and so on.

The script that is being run needs to know what channel is being used to open the call out to the customer so that in the event the customer chooses to not answer the call they can send a call back to the server and the server can drop the second call leg and redirect the call to their voicemail.

So stepwise:

  1. Caller calls in and the chooses press 1 for sales
  2. We dial out the sales person’s cell phone.
  3. We simultaneously send a push notification to the cell phone that asks them to decide if they want to take the call or not.
  4. If they choose not to they touch a button on the screen that says “Send to Voicemail” which calls back to the server to tell it to do this with the call.
  5. The server can then hopefully drop the channel out to the cell phone and redirect the caller to voicemail.

Hopefully this helps, thanks for your advice!

Why can’t you use the normal call rejecting mechanisms from the mobile phone?

You can use the & syntax to start a local channel in parallel with the all to the mobile.

Not sure why you need to push incoming call notification. Your VSP should let you set the caller id to anything you want.
If your current one does not, switch to a different one who does or at least get another provider for sending outbound calls through for this particular project.

The reason is because I don’t want to give simply the reject or accept option, I would also like an option to transfer somewhere else so the app on the phone makes this required.

Yes you can do that using AMI

Any idea how? After I dial I assume I can somehow run sip show channels and then using the phone number get the call id and then run sip show channel and get the channel id, then finally using redirect or something like that I can move the original call somewhere else? Thanks for the help!

check this link:

Basically you need to monitor your desired sip exten and get the channel via the AMI and run your program.

Just as a finish to this, we ended up running a listener in Java that watched for the join events and recorded the call ids. Then we used these later on to redirect the call, etc. to get it to what we wanted it to do. So far it works great, thanks for everyone’s help!