Asterisk DTMF Read digits and dial.

Posted on 2009-04-20
Last Modified: 2013-12-21
I need to create a listener for asterisk.  Basically, only during an active call, the agent can transfer to a predefined number by pressing * or # or any
DTMF tone.

Basically if during a call the agent presses * it will transfer them to a specific number i have predefined.

What i have so far is in the code box.

I would assume it would be something like :
exten => 10,1,Read(digit,,1)
exten => if digit is * then dial (SIP/context/number)

i just dont know the syntax.
exten => 100,1,Read(digit,,1)

exten => 100,2,Dial(${digit})

Open in new window

Question by:THEROMPSTER2000
    LVL 9

    Expert Comment

    MAybe something like this :

    exten => 10,1,Answer()
    exten => 10,n,Read(DIALEDDIGIT||1)
    exten => 10,n,GotoIf("${DIALEDDIGIT}" = "*"?dialmy,1)

    exten => dialmy,1,Dial(SIP/context/number)
    LVL 19

    Accepted Solution

    You want this to work "during an active call". Does that mean that Asterisk has already connected the two parties (caller and called) together? If so, then you must look at features.conf:

    You have two choices:
    1. Use blind transfer or attended transfer in the [featuremap] section along with pre-setting the variable __TRANSFER_CONTEXT so that you can define the steps you want it to execute in the dial plan when they press the transfer key
    2. Use [applicationmap]

    You must also look at the t option in the Dial command that initially establishes the original call.

    As for the correct steps/commands to use in the TRANSFER_CONTEXT section, you will have to experiment to see what is right. Possibly the Dial command will do what is required. There is also a transfer command, but I have never used it:

    You will be able to see what is happening in the dial plan script if you go to the Asterisk CLI and type "core set verbose 3". You can also add Noop lines to your dial plan to help you trace through the steps that it is executing and to inspect the values of variables. First, get Asterisk to respond to the key press during the call by setting a value in features.conf and adding option t to your original Dial command. Then set the TRANSFER_CONTEXT and check it is going into this context, finally work on finding the right steps to put within that context to give you the required result.

    Author Comment

    Ok this is what i have in features.conf

    transferdigittimeout => 6

    how can i do what you mean with the transfer_context, where would i do that?
    LVL 19

    Expert Comment

    First, you would need to create a new context in the dial plan. Call it, say, [mytransfers]

    Then you would set the transfer_context in a step just before the Dial command that sets up the original call. For example:
    exten => 123,n,Set(__TRANSFER_CONTEXT=mytransfers)
    exten => 123,n,Dial(...,t)

    While the call is active, the execution of the steps in your dial plan is effectively paused, waiting for the Dial command to complete (i.e. it won't return from the Dial command and execute more steps if the call has been established successfully). However, if a caller presses ## or *2 your dial plan should resume execution in the context [mytransfers]. If you want the trigger to be a single key press then edit the blindxfer or atxfer parameters in features.conf.

    Author Closing Comment

    Thank you very much your answer guided me in the right direction.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    In my office we had 10 Cisco 7940G IP phones that were useless as they were showing PROTOCOL APPLICATION INVALID when started. I searched through Google and worked for a week continuously on those phones, and finally got them working. This is a di…
    Hey there Heard about jingle, the add on for XMPP that enables point to point audio between two XMPP clients. No server config necessary. Actually quite a cool feature. However, how good is it if you can not use those voice capabilities to do a P…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now