adhearsion-asterisk

adhearsion-asterisk is an Adhearsion Plugin providing Asterisk-specific dialplan methods, AMI access, and access to Asterisk configuration.

Features

Dialplan methods

Asterisk configuration generators

Requirements

Install

Add adhearsion-asterisk to your Adhearsion app's Gemfile.

Examples

Dialplan

class Voicemail < Adhearsion::CallController
  def run
    voicemail "8000"
  end
end

class EchoTest < Adhearsion::CallController
  def run
    play 'demo-echotest'
    execute 'Echo'
    play 'demo-echodone'
  end
end

class SayTime < Adhearsion::CallController
  def run
    t = Time.now
    date = t.to_date
    date_format = 'ABdY'
    execute "SayUnixTime", t.to_i, date_format
    play_time date, :format => date_format
  end
end

class CallQueue < Adhearsion::CallController
  def run
    case variables[:x_agi_extension]
    when 5001
      queue 'sales'
    when 5002
      queue 'support'
    end
  end
end

class SalesAgent < Adhearsion::CallController
  def run
    queue('sales').join!
  end
end

class SupportAgent < Adhearsion::CallController
  def run
    queue('support').join!
  end
end

class Operator < Adhearsion::CallController
  def run
    enable_feature :blind_transfer
    dial extension, :options => "Tt"
  end
end


Config generation

Stand-alone example

require 'adhearsion/asterisk'
require 'adhearsion/asterisk/config_generator/voicemail'

config_generator = Adhearsion::Asterisk::ConfigGenerator::Voicemail.new
asterisk_config_file = "voicemail.conf"

File.open(asterisk_config_file, "w") do |file|
  file.write config_generator
end

agents.conf, and queue.conf can be done similarly.

Author

Original author: Ben Langfeld

Contributors: * Taylor Carpenter

Links

Note on Patches/Pull Requests

Copyright

Copyright (c) 2012 Adhearsion Foundation Inc. MIT license (see LICENSE for details).