I am trying to consume data from an API to build an IVR in asterisk 11. The CURL call works fine and I get back a JSON array of the data. However, I want to extract the value from specific elements to build an IVR.
Actually, I have an Interactive IVR but it is working with odbc connector which reads the information in a remote MySQL database, this is how it works:
- A person dials a toll free number
- If is a client press 2, If is not client , dial 1 and goes to a Sales queue
- if its client, press 2, then asterisk ask for the number of client, after client number is entered, asterisk reads a field called "deuda" and it plays the amount of money on the account.
- then the ivr plays the options to pay the debt, or ask for technical support.
I want to do this with the API, I can curl the API this way:
curl -s 'https://api.wisphub.net/api/clientes/' \ --header 'Authorization: Api-Key myapikey' |jq '.'
The result is:
Result of CURL
then based on that, I build the dialplan
exten => 815,1,Read(Servicio,Numero_Servicio,6)
same => n,Set(CURL_RESULT=${SHELL(curl -s 'https://api.wisphub.net/api/clientes/' \ --header 'Authorization: Api-Key myapikey' |jq -r '.')})
same => n,Playback(oxxo)
same => n,SayAlpha(${CURL_RESULT})
I want to build an interactive IVR getting information from an external API