Nice Adhearsion tidbits

November 11, 2010

Some useful tips gathered from the #adhearsion irc room:

Adhearsion-Asterisk dialplan integration

In the old days when you wanted to send a call from asterisk into adhearsion you needed to do it from a context that was named the same as your adhearsion context, well not any more, as adhearsion 0.8.5+ allows you to do the following

[any_context]
exten => 1234,1,AGI(agi://127.0.0.1/your_ahn_context)

and in your adhearsion dialplan

your_ahn_context {
  answer
}

Much easier, you dont need to deal with Macro(), GoTo() or the exten => s extension, simply call any adhearsion context from any asterisk extension

Originate back to Adhearsion

A call created with Originate does not need to be sent to the dialplan but it can be sent directly to Adhearsion thus reducing the amount of dialplan needed for adhearsion applications, this might make integration with asterisk distributions like trixbox/elastix more straightforward.

So instead of setting a context/extension/priority:

Adhearsion.originate({
  :channel    => channel,
  :context    => context,
  :exten      => "s",
  :priority   => 1,
  :callerid   => number_to,
  :timeout    => 30000,
  :async      => 'true' 
})

We can now do the following:

Adhearsion.originate({
  :channel      => channel,
  :application  => 'AGI',
  :data         => 'agi://127.0.0.1/your_ahn_context',  #or your adhearsion AGI URI (with context)
  :callerid     => number_to,
  :timeout      => 30000,
  :async        => 'true' 
})

This takes advantage of both adhearsion 0.8.5+ ability to route to the call according to the AGI URL path (as per the above point) and the ‘originate to application’ feature of Asterisk Manager Originate command itself. No longer required to specify a context an exten or a priority

sweet :) less moving parts

Adhearsion Call Tagging

Adhearsion has built-in call tagging functionality, in dialplan.rb:

  self.tag(:mytag)
#(the symbol can be anything of your choosing, or a string)
  self.tags # yields an array of tags associated with the current call
  self.tagged_with?(:mytag) #  boolean
# and finally,
  self.remove_tag

if you’re doing it in events.rb or in a component you’ll have to get a handle on the call object first. You can do that like:

  Adhearsion::Calls.with_tag(:mytag) # an array of call objects with that tag

tagging only works on calls that are connected via AGI

Dial confirmation

This is a bit of a mistery, but it is said that there is an option called :confirm for the dial adhearsion application, not sure how it works but will try to research it

Comments

comments powered by Disqus