Using Adhearsion with Asterisk


To use Asterisk with Adhearsion you must be using Asterisk version 1.8.4 or later. If you do not know which version to pick, we strongly recommend choosing a Long Term Support, or "LTS", release. LTS releases are supported by Digium for a much longer period of time and are appropriate for production deployment. At the time of this writing Asterisk 1.8 is the current LTS release and the next LTS release, Asterisk 11, is in beta.

Getting Asterisk

Asterisk Packages

For many platforms the easiest way to install Asterisk is to use the packages provided by your operating system or distribution. At the time of this writing, the following Linux distributions provide a suitable version of Asterisk for use with Adhearsion 2.0:

In addition to the vendor-provided packages above, Digium provides packages for several common distributions:

Compiling Asterisk

If you are not able to obtain packages for your operating system, Asterisk can be compiled on many additional platforms, including FreeBSD, Mac OSX and even Solaris. Please see the Asterisk installation documentation for further information.

Configuring Asterisk

AMI User

It is necessary to configure an AMI user by which Adhearsion can connect to Asterisk. This can be done in /etc/asterisk/manager.conf, and a sample configuration is provided below:

enabled = yes
port = 5038
bindaddr =

secret = mypassword
read = all
write = all
eventfilter = !Event: RTCP*
eventfilter = !Variable: RTPAUDIOQOS*

Note that the user needs acess to all AMI events and actions. Also, we have setup an event filter here to prevent sending Adhearsion RTCP and QOS events. This is optional, but recommended, because while Asterisk generates a great number of these events Adhearsion cannot normally do anything useful with them. Thus, we can improve Adhearsion's performance by not sending it these events in the first place.

Route calls to AsyncAGI

To process calls with Adhearsion they must be routed through AsyncAGI. Add the following contexts your /etc/asterisk/extensions.conf:

exten => _X.,1,AGI(agi:async)

exten => 1,1,AGI(agi:async)

This will route all calls that hit the "adhearsion" context to your Adhearsion application. To get calls into the "adhearsion" context, you should configure your SIP peers or Dahdi or other channels to have "context=adhearsion" in their configuration. Please consult the Asterisk documentation for more information on setting up peers and channels.

Configuring Adhearsion for Asterisk

As always the full list of configuration options can be viewed, along with a description and their default values, by typing rake config:show in your application directory. There are a few configuration options that are particularly important:

  • config.punchblock.platform must be set to :asterisk
  • config.punchblock.username must be set to your AMI username (eg. "myuser")
  • config.punchblock.password must be set to the password recorded in manager.conf (eg. "mypassword")
  • If you are using any text-to-speech or speech recognition engine, you must set config.punchblock.media_engine appropriately. Common values for use with Asterisk are :unimrcp or :swift.

Note that as described in our Deployment Best Practices, we recommend NOT storing the AMI username and password in the config/adhearsion.rb file. Instead these should be stored in environment variables (notably: AHN_PUNCHBLOCK_USERNAME and AHN_PUNCHBLOCK_PASSWORD) that are loaded by the process prior to launching.

Getting Help

If you need help configuring Asterisk there are several resources available:

  • The Asterisk Wiki - The official Asterisk wiki maintained by Digium. This has excellent reference information and is the most up-to-date. Note that while it contains great reference information it tends to lack "how to" guides or very many example configuration scenarios.
  • Wiki - The original community wiki for all things Voice over IP. This is a fantastic resource with many years of documentation compiled. Note that much of the information is out of date however, especially for Asterisk. As you read it, make sure the content applies to the version of Asterisk you are running!
  • Asterisk-Users Mailing List - The Asterisk-Users mailing list is a great community resource that also is monitored by the Asterisk developers at Digium.
  • Adhearsion Community Support - As always we invite you to post your questions to the Adhearsion community via IRC or our own mailing list.

docs-nav-getting-started docs-nav-getting-started-installation

blog comments powered by Disqus