Simple Dialplan question

I have pieced to gether a simple plan to retrieve data from a DB and route the caller by using that info. Admittedly I copied this from a source online. I have manipulated it to my abilities. The caller should be transferred to an IVR depending on the result of the query. So far I can get to the Hangup and or the Try again later, so I know my Query is working. So I need to send the caller to an IVR depending on the result. Thanks

exten => 9001,1,Answer()
same => n,Playback(custom/dealerid)
same => n,Read(pinnumber,beep,4,,1,10)
same => n,MYSQL(Connect connid localhost ivruser password dealers)
same => n,MYSQL(Query resultid ${connid} SELECT level from info where dealerid=${pinnumber})
same => n,MYSQL(Fetch fetchid ${resultid} level)
same => n,MYSQL(Disconnect ${connid})
same => n,NoOp(&& the value found is ${level} )

same => n,ExecIf($["${level}"="authorised"]?playback(hangup-try-again))
same => n,ExecIf($["${level}"="authorised"]?HANGUP())

same => n,PlayBack(auth-thankyou)
same => n,Hangup()

Goto with ${level} as the extension.

I’m sorry I’m not following.

same => n,Goto(${level},1)

although you may want to change context as well, or use GoSub.

Thanks david551 I got it to work. Another question comes to mind.
I am using Playback and Read to get a 4 digit number from the caller for the query. The caller needs to wait until the playback file is done before entering their digits. I know there is the Background command to allow the caller to dial over the message. But just substituting Background for Playback the dialplan breaks. Is there a way to use Background in this instance?

You can’t use read, you have to use extensions that match the user input.

Got it, I’ll have to use it as it is

Yep. With ‘extension pattern matching.’

For example:

        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       background(demo-congrats)
        same = n,                       goto(1)

        exten = i,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       goto(s,1)

        exten = _xxxx#,1,               verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       set(ENTRY=${EXTEN})
        same = n,                       verbose(1,[${EXTEN}@${CONTEXT}!${ENTRY}])

        same = n,                       hangup()

The pattern would need to be used in the MySql query as a variable.

You are correct. Mash up your snippet and mine and “Bob’s your uncle.”

1 Like

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