text stringlengths 0 152 |
|---|
While you’ll find CURL() itself to be quite simple to use, the creation of the web appli‐ |
cation will require experience with web development. |
func_odbc |
Using func_odbc, it is possible to develop extremely complex applications in Asterisk |
using nothing more than dialplan code and database lookups. If you are not a strong |
programmer but are very adept with Asterisk dialplans and databases, you’ll love |
func_odbc just as much as we do. Check it out in Chapter 15. |
AGI |
The Asterisk Gateway Interface is such an important part of integrating external |
applications with Asterisk that we gave it its own chapter. You can find more infor‐ |
mation in Chapter 18. |
AMI |
The Asterisk Manager Interface is a socket interface that you can use to get configura‐ |
tion and status information, request actions to be performed, and be notified about |
things happening to calls. We’ve written an entire chapter on AMI as well. You can |
find more information in Chapter 17. |
ARI |
Asterisk’s REST interface builds on knowledge gained over the years about how to |
integrate Asterisk with current-generation web-centric applications. It is so impor‐ |
tant, that yes, once again, there is a complete chapter dedicated to it. If you’re looking |
to build complex IVRs using Asterisk, take a closer look at ARI in Chapter 19. |
Asterisk Modules for Building IVRs |
| |
293 |
A Simple IVR Using CURL() |
Before we go running off writing an external program to handle something, we |
always give some careful thought about whether there’s a way to do the work in the |
dialplan. One powerful way that Asterisk can interact with external data is through a |
URL, which the GNU/Linux program cURL does very well. In Asterisk, CURL() is a |
dialplan function. |
We’re going to use CURL() as an example of what an extremely simple IVR can look |
like. We’re going to request our external IP address from https://ipinfo.io/ip.2 |
In reality, most IVR applications are going to be far more complex. |
Even most uses of CURL() will tend to be complex, since a URI can |
return a massive and highly variable amount of data, the vast |
majority of which will be incomprehensible to Asterisk. The point |
being that an IVR is not just about the dialplan; it is also very much |
about the external applications that are triggered by the dialplan, |
which are doing the real work of the IVR. |
The CURL() module was installed during our installation process several chapters ago. |
The Dialplan |
The dialplan for our example IVR is very simple. The CURL() function will retrieve |
our IP address from https://ipinfo.io/ip, and then SayAlpha() will speak the results to |
the caller: |
exten => *764,1,Verbose(2, Run CURL to get IP address from whatismyip.org) |
same => n,Answer() |
same => n,Set(MyIPAddressIs=${CURL(https://ipinfo.io/ip)}) |
same => n,SayAlpha(${MyIPAddressIs}) |
same => n,Hangup() |
The simplicity of this is impossibly cool. In a traditional IVR system, this sort of thing |
could take days to program, assuming it would be possible at all. |
A Prompt-Recording IVR Function |
In Chapter 14, we created a simple bit of dialplan to record prompts. It was fairly |
limited in that it only recorded one filename, and thus for each prompt a separate |
2 These free IP lookup websites seem to get bought out all the time, and turned into advertising gateways, so |
what might have worked at this writing may no longer work. What you need is a website that will return your |
IP address, and nothing else. Today, that seems to be https://ipinfo.io/ip. By the time you read this, it may be |
something else. |
294 |
| |
Chapter 16: Introduction to Interactive Voice Response |
extension was needed. Here, we expand upon that to create a complete menu for |
recording prompts. Since this is a complex bit of dialplan, but it’s not a subroutine or |
a local channel, we’re going to create a new section of dialplan for various features, |
and put things like this there: |
;FEATURES |
[prompts] |
exten => s,1,Answer |
exten => s,n,Set(step1count=0) ; Initialize counters |
; If we get no response after 3 times, we stop asking |
same => n(beginning),GotoIf($[${step1count} > 2]?end) |
same => n,Read(which,prompt-instructions,3) |
same => n,Set(step1count=$[${step1count} + 1]) |
; All prompts must be 3 digits in length |
same => n,GotoIf($[${LEN(${which})} != 3]?beginning) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.