Use Dialplan Variables From MySQL Database And Replace With Value

Home » Asterisk Users » Use Dialplan Variables From MySQL Database And Replace With Value
Asterisk Users 1 Comment

Hello

i have the following field (text string) in a MySQL database :
“${KNUMMER} ${phone_number_to} ${phone_number_from} ${CHANNEL:4}”

I read this string form the database and want to have the dialplan variables to be replaced with the correct content.

How can I do this ?

Currently this is not working. The variable ${PARAMS} contains the exact string of the database field :

my dialplan :

exten => s,n,MYSQL(Connect connid localhost dbuser dbpass MyTable)
exten => s,n,MYSQL(Query resultid ${connid} SELECT script_url, script_params FROM my_tbl WHERE ID=”${myID}”)
exten => s,n,MYSQL(Fetch fetchid ${resultid} scriptURL PARAMS)
exten => s,n,NoOp(scriptURL = ${scriptURL} PARAMS = ${PARAMS})

becomes :

— Executing [s@sub-details:4] MYSQL(“SIP/SipT01-00000012”, “Connect connid localhost dbuser dbpass MyTable”) in new stack
— Executing [s@sub-details:5] MYSQL(“SIP/SipT01-00000012”, “Query resultid 1 SELECT script_url, script_params FROM my_tbl WHERE ID=”2″”)
in new stack
— Executing [s@sub-details:6] MYSQL(“SIP/SipT01-00000012”, “Fetch fetchid 2 scriptURL PARAMS”) in new stack
— Executing [s@sub-details:7] NoOp(“SIP/SipT01-00000012”, “scriptURL call_end.php PARAMS = ${KNUMMER} ${phone_number_to} ${phone_number_from}
${CHANNEL:4}”) in new stack

If the variable ${PARAMS} contains other variables ” ${KNUMMER}
${phone_number_to} ${phone_number_from} ${CHANNEL:4} “, how can I use the values of these variables in my dialplan ??

I want to use “${KNUMMER} ${phone_number_to} ${phone_number_from}
${CHANNEL:4} ” as input to my script inside my dialplan :

— Executing [h@pbx-routing:43] System(“SIP/SipT01-00000012”,
“/usr/bin/php /var/lib/asterisk/agi-bin/call_end.php ${KNUMMER}
${phone_number_to} ${phone_number_from} ${CHANNEL:4}”) in new stack

But in stead of having ${KNUMMER} I want to have “112233”, and in stead of having ${phone_number_to} I want to have “31023456789” and so on…

Is this possible ??

Kind regards,

Jonas.

One thought on - Use Dialplan Variables From MySQL Database And Replace With Value