ASTERISK & PHP. Hans-Christian Otto International PHP Conference 2010 SE Berlin, June 1, 2010



Similar documents
NOC Workshop VoIP in the NOC labs SANOG10

Asterisk Basics (SIP)

VoIP Workshop PacNOG3

Overview of Asterisk (*) Jeff Gunther

Ryan Brown October 9, 2004 The Burgh Live, LLC. Voice over IP using Asterisk (*)

VOIP with Asterisk & Perl

Grandstream Networks, Inc. UCM6100 Series IP PBX Appliance CDR and REC API Guide

Telephony with an Asterisk phone system

Open Source Telephony Projects as an Application Development Platform. Frederic Dickey Director Product Management

Mediatrix 3000 with Asterisk June 22, 2011

Using Polycom KIRK Wireless Server 300 or 6000 with Asterisk

The IP-Private Branch Exchange (PBX)

Asterisk & ENUM. Extending the Open Source PBX. Michael Haberler, IPA Otmar Lendl, nic.at

An introduction to PHP & AGI

Allow Auto Answer by Call-Info: No Yes. Turn off speaker on remote disconnect: No Yes

Quick Provisioning Guide for Third-Party PBX

Crash Course in Asterisk

Asterisk: The Open Source PBX Solution Adam Olson Systems and network administrators typically deal with

You da M.A.N. Voice, over IP, over stuff

Micronet VoIP Solution with Asterisk

Grandstream Networks, Inc. Asterisk PBX Configuration Guide GXP21xx IP Phone/GXP1450 IP Phone

LessWires Advanced IP Soft-PBX System

Applications between Asotel VoIP and Asterisk

Introduction to Asterisk

Guideline for SIP Trunk Setup

Asterisk By Example...doing useful VoIP things. Jonny Martin

OpenVox GSM Gateway Function Manual

Asterisk. Michael Kershaw

TEL-500 Project Report. Auto-Dialler System. Voice Communications. Done By: - AKASH ANANTHANARAYANAN SANJEEVAKUMAR DEVARAJA

Evolution PBX User Guide for SIP Generic Devices

Introduction. What is DUNDi? Configuring Asterisk for use with DUNDi

Setup the Asterisk server with the Internet Gate

Using the GS8 Modular Gateway with Asterisk

iview (v2.0) Administrator Guide Version 1.0

Internet telephony Asterisk system.

DUNDi, So Easy A Caveman Could Do It!

VoIP Laboratory C VoIP Billling in a Village Telco

SIP Trunk Configuration for Broadvox

Basic configuration of the GXW410x with Asterisk

PBXware End User Guide Bicom Systems

AGILE SIP TRUNK IP- PBX Connection Manual (Asterisk, Trixbox)

Configuring the Cisco SPA8800 IP Telephony Gateway in an Asterisk Environment

Introduction to Asterisk

TEL 500 VOICE COMMUNICATIONS PROJECT REPORT IMPLEMENTATION OF SMALL CALL CENTER WITH AUTO ATTENDENT AND QUEUES SUBMITTED TO: RONNY L.

Chapter 1 - Introduction

VOIP, Linux, and Asterisk Making Beautiful Voice Together

Trixbox. by MATT FLORELL and JAMES PEARSON

A System for Auto-Provisioning VOIP Telephones for Asterisk

Unicorn60x0 IP ANALOG GATEWAY ASTERISK CONFIGURATION

IP PBX. SD Card Slot. FXO Ports. PBX WAN port. FXO Ports LED, RED means online

Atcom MP01 and Elastix Server

How To Use A Voicenet Premium Hosted Pbx On A Cell Phone (For A Simplon) On A Simpson Or Ipa Or Ipbx (For An Ipb) On An Ipa (For Simpson)

Skype connect and Asterisk

B rismark. Open Source IP PBX The Future of Telephony. T: W:

AGILE SIP TRUNK IP-PBX Connection Manual (Asterisk)

NodePhone Business Trunks User Manual

Using Asterisk with Odin s OTX Boards

Test on IX130 Performance

Fig. Setting up of a VoIP call. Fig. Experimental setup

Wildix Management System (WMS) White Paper

Configuring Elastix for Spitfire SIP Trunks

Configurator Administrators Guide

and Voice Applications Eyal Wirsansky, Verso Technologies JaxJUG

PBX Manager Portal v2.0

IP- PBX. Functionality Options

Trunks User Guide. Schmooze Com Inc.

Asterisk Voice Exchange: An Alternative to Conventional EPBX

Asterisk PBX Features

Asterisk Calling Card & Billing System

Abstract. Avaya Solution & Interoperability Test Lab

Merging Old and New Telephony with Asterisk

Asterisk Overview and Interfacing with APAN Server

L3DGEWorld Asterisk Management System (LAMS)

Exchanging Phonecalls Asterisk offers a low-budget

Telco Depot IP-PBX Software Features

IP-PBX Quick Start Guide

FreePBX R14. SIP Trunk Provisioning Guide

Dashboard...4. Agents...5 SIP Queues Trunk Dial Plan Audio Cally Square Pre Analytics Settings...

Configuration Notes 290

ACD Automatic Call Distribution

Voice Rate Plans. A Call Path + Inbound Phone Number combination is commonly referred to as a Phone Line.

Asterisk Voic User Reference

VOIP and Ruby. The Convergence of Web and Voice Applications using Open Source Software. Justin Grammens Localtone Interactive

SFLphone Documentation

Thirdlane PBX Manager Users Guide 12/04/2007. Third Lane Technologies, LLC 39 Power Lane Fairfax, CA

TEL 500 WRITE UP WEEK 8 FREE PBX SIP LAB SUBMITTED TO: PROF. RONNY BULL BY: ANUSHA ALIGAPALLY

A Guide to Connecting to FreePBX

Xorcom IP-PBX Software Features

Using DUNDi with a Cluster of Asterisk Servers! General Description and Scope

How to Configure MTG200 with FreePBX

icalldroid User Manual

VoIP Services User Guide

Transcription:

ASTERISK & PHP Hans-Christian Otto International PHP Conference 2010 SE Berlin, June 1, 2010 1

ABOUT ME PHP since 2004 Asterisk since 2007 working as a freelancer for various companys computer science student at TU Dortmund active member of phpugdo 2

AND YOU? 3

ASTERISK open source PBX actually dual-licensed created by Mark Spencer in 1999 runs on *nix and windows VoIP ISDN bluetooth and more 4

InterAsterisk exchange Session Initiation Protocol H.323 UNIStim Voice over Frame Relay- Protokoll SCCP SS7 Euro-ISDN (DSS1) 4ESS QSIG DMS100 Lucent 5E Distributed Switching National ISDN2 NFAS Wikipedia, Die freie Enzyklopädie. Bearbeitungsstand: May 28, 2010, 10:49 pm UTC. URL: http://de.wikipedia.org/w/index.php?title=asterisk_(telefonanlage)&oldid=74905428 5

FEATURES music on hold voicemail phone conferences IVR AstDB queues call parking pickup speech recognition follow me scriptable 6

USE CASES 7

DIALING 8

INCOMING CALLS 9

MISSED CALLS 10

SOME TERMS device dialplan extension context channel 11

DEVICES SIP peers SIP phones softclients IAX peers bluetooth devices etc. legacy phones using ATA sip providers isdn phones 12

DIALPLAN contexts extension priority applications macros control structures 13

SIP.CONF [alice] type=friend context=from-sip secret=passwordalice host=dynamic disallow=all allow=ulaw allow=alaw [bob] type=friend context=from-sip secret=passwordbob host=dynamic disallow=all allow=ulaw allow=alaw 14

EXTENSIONS.CONF [from-sip] exten => 10,1,Dial(SIP/alice&SIP/bob) exten => 11,1,Dial(SIP/alice) exten => 11,hint,SIP/alice exten => 12,1,Dial(SIP/bob) exten => 81,1,Answer() exten => 81,2,AGI(weather.agi) exten => 81,3,Hangup() 15

IVR exten => 90,1,Answer() exten => 90,n,Playback(marryme) exten => 1,1, Playback(thank-you-cooperaation) exten => 1,n, Hangup() exten => 2,1, Playback(sorry) exten => 2,n, Hangup() 16

CONTROL STRUCTURES exten => 123,1,Answer exten => 123,n,Set(i=1) exten => 123,n,While($[${i} < 5]) exten => 123,n,SayNumber(${i}) exten => 123,n,Set(i=$[${i} + 1]) exten => 123,n,EndWhile 17

AEL context ael-demo { 123 => { Answer(); for (x=0; ${x} < 5; x=${x} + 1) { SayNumber(${x}); }; } 18

LUA function demo_start(context, exten) app.wait(1) app.answer() demo_congrats(context, exten) end extensions = { demo = { s = demo_start; ["2"] = function() app.background("demo-moreinfo") demo_instruct() end; } } 19

FUNFACT AEL and extensions.conf support goto for a long time ;-) 20

PHP? dialplan AGI FastAGI AMI AJAM callfiles 21

STATE OF ASTERISK & PHP multiple php libraries freepbx 22

USE CASES 23

DIALING SUCKS. dialing results in missdialing procrastination; not misdialing calls (laziness) using (more expensive) cellphones solution: computer based dialing AMI callfiles 24

CALLFILES text files initiating a call Channel: SIP/alice key-value pairs placed in a special directory watched by asterisk schedule calls by mtime modification Context: from-sip Extension: 12 Priority: 1 WaitTime: 30 RetryTime: 60 MaxRetries: 2 25

<?php $filename = tempnam( '/var/spool/asterisk/tmp/', 'callfile' ); file_put_contents($filename, $callfile); touch($filename, time() + 60); rename( $filename, tempnam( '/var/spool/asterisk/outgoing/', 'callfile' ) ); 26

INCOMING CALL display notifications on client computers using funny gadgets (emergency lights, anyone?) turn off espresso maker (so your staff gets back to work) entertain caller log (missed) calls visualize in CRM 27

CDR log all calls different output modules csv mysql etc. 28

CDR_MYSQL.CONF [global] hostname = localhost dbname=asteriskcdrdb password = amp109 user = asteriskuser userfield=1 29

calldate: 2010-05-29 11:26:18 clid: "Extern: 123" <123> src: 123 dst: 31 dcontext: from-internal channel: SIP/9-09bde8f8 dstchannel: SIP/31-09bb7550 duration: 22 billsec: 11 disposition: ANSWERED amaflags: 3 accountcode: uniqueid: 1275125178.20185 userfield: lastapp: Dial lastdata: SIP/31 20 30

AGI executables chmod +x & shebang receive variables through STDIN just like HTTP-headers, Key: Value send commands through STDOUT fwrite(stdout,"exec Playback tt-allbusy \"\"\n"); PHPAGI 31

A SIMPLE AGI #!/usr/bin/env php <?php require 'phpagi/phpagi.php'; $agi = new AGI(); $agi->text2wav('please enter the PIN.'); $pin = $agi->get_data( 'beep', 5000, 4 ); if( $pin['result']!= '2342' ) { $agi->text2wav('the entered pin was wrong.'); } else { start_servers($agi); } 32

A SIMPLE AGI } function start_servers($agi) { $agi->text2wav('which server should be started?'); $server = $agi->menu(array( '1' => '*Press 1 for CRM', '2' => '*Press 2 for ERP', )); $agi->text2wav('waking up server '. $server); WakeOnLan($server); 33

WHO S CALLING? #!/usr/bin/env php <?php require 'phpagi/phpagi.php'; $agi = new AGI(); $cid = $agi->getvariable('callerid(name)'); if(!$cid['result']) exit; $agi->set_callerid(sprintf( '"%s"<%d>', lookupnamebynumber($cid['data']), $cid['data'] )); 34

WHO S CALLING? exten => 11,1,AGI(callerid_lookup) exten => 11,2,Dial(SIP/alice) 35

PHP & PHONES XML browser directory lookup missed call list busy lamp field action buttons 36

BUSY LAMP FIELD indicates status of phones using hints available ringing busy/unavailable can indicate devstate 37

DEVSTATE can be controlled using dialplan exten => 23,n,Set(DEVSTATE(Custom:foo) = RINGING) cli command devstate change Custom:foo RINGING AMI 38

DEVSTATE: USECASES presence non-phone indicators escalating support ticket system status (nagios?) build failures? ;-) 39

MISSED CALLS common asterisk issue: missed calls possible solution: CDR / AGI and XML application / webgui 40

CONCLUSION PHP can originate calls interact with calls interact with caller interact with callee analyze logs enrich phones 41

CONTACT http://hans-christian-otto.de/ c.otto@lab9.de @muhdiekuh muh-die-kuh @ euirc / freenode 42

FURTHER REFERENCES http://das-asterisk-buch.de/ (german, source for some examples) http://www.the-asterisk-book.com/ http://eder.us/projects/phpagi/ http://www.voip-info.org/ http://www.asterisk.org/ 43