Skip to content

smpallen99/speak_ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

speak_ex

An Elixir framework for building telephony applications, inspired heavily by Ruby's Adhearsion.

SpeakEx enables easy integration of Elixir and Phoenix voice applications with Asterisk. For example, build a simple voice survey application with Elixir Survey Tutorial or a call out system.

Getting Started

Configure Asterisk

Configure some extensions to be routed to the SpeakEx application.

/etc/asterisk/extensions_custom.conf

[from-internal-custom]
include => speak-ex

[speak-ex]
exten => _5XXX,1,Noop(SpeakEx Demo)
exten => _5XXX,n,AGI(agi://10.1.2.209:20000)

Configure an account for AMI.

/etc/asterisk/manager.conf

[elixirconf]
secret = elixirconf
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
writetimeout = 5000

Reload asterisk with asterisk -rx reload

Setup your Elixir project

Install the dependency

mix.exs

      ...
      {:speak_ex, "~> 0.4"},
      ...

Fetch and compile the dependency:

mix do deps.get, deps.compile

Configure AGI and AMI in your elixir project

SpeakEx uses both ExAmi and erlagi. Configuration is needed for both as follows:

config/config.exs

  config :erlagi,
    listen: [
      {:localhost, host: '127.0.0.1', port: 20000, backlog: 5,
          callback: SpeakEx.CallController}
    ]

  config :ex_ami,
    servers: [
      {:asterisk, [
        {:connection, {ExAmi.TcpConnection, [
          {:host, "127.0.0.1"}, {:port, 5038}
        ]}},
        {:username, "elixirconf"},
        {:secret, "elixirconf"}
      ]} ]

Configure swift for text-to-speech

If you want to use text to speech and have Cepstral installed on Asterisk, add the following:

config/config.exs

config :speak_ex, :renderer, :swift

Create a voice route

Create a call router to route all incoming calls to the CallController.

lib/call_router.ex

defmodule Survey.CallRouter do
  use SpeakEx.Router

  router do
    route "Survey", MyProject.CallController # , to: ~r/5555/
  end
end

Create a call controller to handle your call

A sample call controller to answer the call say welcome and hang up.

lib/call_controller.ex

defmodule MyProject.CallController do
  use SpeakEx.CallController

  def run(call) do
    call
    |> answer!
    |> say(welcome)
    |> hangup!
    |> terminate!
  end
end

More documentation is coming soon.

License

speak_ex is Copyright (c) 2015-2017 E-MetroTel

The source code is released under the MIT License.

Check LICENSE for more information.

About

An Elixir framework for building telephony applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages