SlideShare a Scribd company logo
Pwning Your Phone ,[object Object]
Past & Today ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Adhearsion in a Nutshell ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why VoIP Rocks ,[object Object],[object Object],[object Object],[object Object],[object Object],(why the lucky stiff???)
Fun VoIP Projects ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dave Troy’s Asterisk-Powered Roomba Dave’s also writing “Telephony with Ruby”. Will be published by The Prags in November
What is  ? What is  ? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Existing Control Grammars Suck At... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],...to name just a few things!
Old Dialplan Example [macro-dial-iax] exten => s,1,SetGlobalVar(FOUNDME=ANSWER)  exten => s,2,GotoIf($[${LEN(${ARG1})} = 10]?2:4)  exten => s,3,SetVar(NumToDial=1${ARG1})  exten => s,4,Goto(s,6)  exten => s,5,SetVar(NumToDial=${ARG1}) ... From extensions.conf
Why Use Adhearsion? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Before Adhearsion.
Before Adhearsion. After Adhearsion.
Other Aspects of Adhearsion ,[object Object],[object Object],[object Object],[object Object],[object Object]
Getting Started
Asterisk?! Isn’t that hard to install? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Installing Adhearsion gem install adhearsion [asterisk-context] exten => _.,1,AGI(agi://127.0.0.1)
Writing Adhearsion Dialplans internal { }
Writing Adhearsion Dialplans internal { play ‘hello-world’ }
Writing Adhearsion Dialplans internal { loop { play ‘tt-monkeys’ } }
Writing Adhearsion Dialplans internal { +foo } foo { record { dial SIP/:out_trunk/1234 } }
Writing Adhearsion Dialplans internal { play %w”a-connect-charge-of 16 cents-per-minute will-apply” }
Writing Adhearsion Dialplans internal { case  extension when   10 ... 100 dial  SIP /extension when   6000 ... 6020 ,  7000 .. 7030 join extension when  _ ' 21XX ' if   Time .now.hour.between?  2 ,  10 dial  SIP / " berlin-office " /extension[ 2 .. 4 ] else  speak  " It is not business hours now  in Germany. " end ...
Writing Adhearsion Dialplans ... when   US_NUMBER dial  SIP / ' us-trunk-out ' /extension when   / ^  {11,}$ / dial  IAX / ' intl-trunk-out ' /extension else play  %w' sorry invalid extension please-try-again ' end }
Database-Driven Dialplans Dialplans service { customer = Account.find_by_phone_number callerid usage = customer.usage_this_month if usage >= 100.hours then +beyond_limit else customer.usage_this_month += time do dial IAX2/'main-trunk'/extension end end } beyond_limit { play %w"sorry your-limit-of 100 hours has-been-reached" }
How Does Adhearsion Talk to Asterisk? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Things you can do from Rails ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Helpers
What’s a Helper? ,[object Object],[object Object],[object Object],[object Object]
Helpers require "hpricot" require "open-uri" def lookup number hash = {} url = " http://www.whitepages.com/9901/search/ReversePhone?phone=#{number} " doc = Hpricot open(url) # This div contains all the information we need, unless it's an unlisted number if (results = doc.at "#results_single_listing") then # This div's h3 contains the name of the caller hash[:first_name], hash[:last_name] = results.at('h3').inner_html.split(/,*/).reverse # Now we just need the rest of the information contained in p's. meta = results/'p' meta.pop # Discard the useless p element hash[:number] = meta.pop.inner_html city_info = meta.pop.inner_html city_info = city_info.match /(.+), ([A-Za-z]{2}) ({5})/ hash[:city]  = city_info[1] hash[:state] = city_info[2] hash[:zip]  = city_info[3] hash[:address] = meta.map(&:inner_html) * " " elsif (results = doc.at "#results_single_phone_info") then meta = results/'span' hash[:location] = (meta.pop.inner_html.match /Location: (.*)/)[1] end if hash[:first_name] or hash[:last_name] then hash[:composite] = "#{hash[:first_name]} #{hash[:last_name]}" else hash[:composite] = hash[:location] end hash end
Helpers (in C) (in C) int fast_factorial(int input) { int prod = 1, count = 1; while(count <= input) { prod *= count++; } return sum; }
Micromenus
Micromenus ,[object Object],[object Object],[object Object],[object Object],[object Object]
Micromenus item 'Adhearsion Server Statistics' do item 'View Registered SIP Users' do PBX.sip_users.each do |u| item &quot;SIP user '#{u.username}' on IP #{u.ip}&quot; end end item 'View System Uptime' do item `uptime` end item 'Network' do heading 'Network Interface Info' `ifconfig eth1`.each_line do |line| item line end end end
Micromenus item 'Call an Employee' do item 'Select an employee below.' User.find(:all).each do |user| call user.extension, user.name end end call 'Join main conference' do play 'welcome' join 5555 end
Where Adhearsion is Headed is Headed ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Get Involved! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

Viewers also liked

Adhearsion and Telegraph Framework Presentation
Adhearsion and Telegraph Framework PresentationAdhearsion and Telegraph Framework Presentation
Adhearsion and Telegraph Framework PresentationJustin Grammens
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is AwesomeAstrails
 
JavaStart - kurs Java Podstawy
JavaStart - kurs Java PodstawyJavaStart - kurs Java Podstawy
JavaStart - kurs Java PodstawyJavaStart
 

Viewers also liked (6)

8 powodów dla których warto poznać Ruby
8 powodów dla których warto poznać Ruby8 powodów dla których warto poznać Ruby
8 powodów dla których warto poznać Ruby
 
Adhearsion and Telegraph Framework Presentation
Adhearsion and Telegraph Framework PresentationAdhearsion and Telegraph Framework Presentation
Adhearsion and Telegraph Framework Presentation
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is Awesome
 
IP PBX
IP PBXIP PBX
IP PBX
 
JavaStart - kurs Java Podstawy
JavaStart - kurs Java PodstawyJavaStart - kurs Java Podstawy
JavaStart - kurs Java Podstawy
 
Asterisk, IM and Presence: how?
Asterisk, IM and Presence: how?Asterisk, IM and Presence: how?
Asterisk, IM and Presence: how?
 

Similar to Pwning Your Phone with Adhearsion and Asterisk

Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"troyd
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Guillaume Laforge
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatBuild HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatSanjay Willie
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsOlle E Johansson
 
Enhancing Free PBX with Adhearsion at Fosdem 2012
Enhancing Free PBX with Adhearsion at Fosdem 2012Enhancing Free PBX with Adhearsion at Fosdem 2012
Enhancing Free PBX with Adhearsion at Fosdem 2012Luca Pradovera
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGI
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGIPhpconf 2013 - Agile Telephony Applications with PAMI and PAGI
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGIMarcelo Gornstein
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Stephan Hochdörfer
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Pythongturnquist
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksGlen Ogilvie
 
X-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackX-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackHaufe-Lexware GmbH & Co KG
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesPaolo Visintin
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsErik Osterman
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Robert Pickering
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Tugdual Grall
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan Osman
 

Similar to Pwning Your Phone with Adhearsion and Asterisk (20)

Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"Stuff we noticed while building "Asterisk in the cloud"
Stuff we noticed while building "Asterisk in the cloud"
 
Ruby voip
Ruby voipRuby voip
Ruby voip
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/HeartbeatBuild HA Asterisk on Microsoft Azure using DRBD/Heartbeat
Build HA Asterisk on Microsoft Azure using DRBD/Heartbeat
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installations
 
Enhancing Free PBX with Adhearsion at Fosdem 2012
Enhancing Free PBX with Adhearsion at Fosdem 2012Enhancing Free PBX with Adhearsion at Fosdem 2012
Enhancing Free PBX with Adhearsion at Fosdem 2012
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGI
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGIPhpconf 2013 - Agile Telephony Applications with PAMI and PAGI
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGI
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13Your Business. Your Language. Your Code - dpc13
Your Business. Your Language. Your Code - dpc13
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
X-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackX-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN Stack
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and Kubernetes
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/Ops
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 

Recently uploaded

PD ARRAY THEORY FOR INTERMEDIATE (1).pdf
PD ARRAY THEORY FOR INTERMEDIATE (1).pdfPD ARRAY THEORY FOR INTERMEDIATE (1).pdf
PD ARRAY THEORY FOR INTERMEDIATE (1).pdfJerrySMaliki
 
is it possible to sell pi network coin in 2024.
is it possible to sell pi network coin in 2024.is it possible to sell pi network coin in 2024.
is it possible to sell pi network coin in 2024.DOT TECH
 
how can I sell/buy bulk pi coins securely
how can I sell/buy bulk pi coins securelyhow can I sell/buy bulk pi coins securely
how can I sell/buy bulk pi coins securelyDOT TECH
 
The new type of smart, sustainable entrepreneurship and the next day | Europe...
The new type of smart, sustainable entrepreneurship and the next day | Europe...The new type of smart, sustainable entrepreneurship and the next day | Europe...
The new type of smart, sustainable entrepreneurship and the next day | Europe...Antonis Zairis
 
how can I sell my locked pi coins safety.
how can I sell my locked pi coins safety.how can I sell my locked pi coins safety.
how can I sell my locked pi coins safety.DOT TECH
 
Latino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino CaucusLatino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino CaucusDanay Escanaverino
 
Juspay Case study(Doubling Revenue Juspay's Success).pptx
Juspay Case study(Doubling Revenue Juspay's Success).pptxJuspay Case study(Doubling Revenue Juspay's Success).pptx
Juspay Case study(Doubling Revenue Juspay's Success).pptxaryan963438
 
Greek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business ReviewGreek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business ReviewAntonis Zairis
 
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理ydubwyt
 
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理zsewypy
 
what is the best method to sell pi coins in 2024
what is the best method to sell pi coins in 2024what is the best method to sell pi coins in 2024
what is the best method to sell pi coins in 2024DOT TECH
 
how can I sell pi coins after successfully completing KYC
how can I sell pi coins after successfully completing KYChow can I sell pi coins after successfully completing KYC
how can I sell pi coins after successfully completing KYCDOT TECH
 
how can I sell my pi coins in China 2024.
how can I sell my pi coins in China 2024.how can I sell my pi coins in China 2024.
how can I sell my pi coins in China 2024.DOT TECH
 
Isios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdfIsios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdfHenry Tapper
 
Webinar Exploring DORA for Fintechs - Simont Braun
Webinar Exploring DORA for Fintechs - Simont BraunWebinar Exploring DORA for Fintechs - Simont Braun
Webinar Exploring DORA for Fintechs - Simont BraunFinTech Belgium
 
9th issue of our inhouse magazine Ingenious May 2024.pdf
9th issue of our inhouse magazine Ingenious May 2024.pdf9th issue of our inhouse magazine Ingenious May 2024.pdf
9th issue of our inhouse magazine Ingenious May 2024.pdfAnkur Shah
 
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理一比一原版UO毕业证渥太华大学毕业证成绩单如何办理
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理yonemuk
 
how can i make money selling pi coins in 2024
how can i make money selling pi coins in 2024how can i make money selling pi coins in 2024
how can i make money selling pi coins in 2024DOT TECH
 
Introduction to Economics II Chapter 25 Production and Growth.pdf
Introduction to Economics II Chapter 25 Production and Growth.pdfIntroduction to Economics II Chapter 25 Production and Growth.pdf
Introduction to Economics II Chapter 25 Production and Growth.pdfSafa444074
 
how can I transfer pi coins to someone in a different country.
how can I transfer pi coins to someone in a different country.how can I transfer pi coins to someone in a different country.
how can I transfer pi coins to someone in a different country.DOT TECH
 

Recently uploaded (20)

PD ARRAY THEORY FOR INTERMEDIATE (1).pdf
PD ARRAY THEORY FOR INTERMEDIATE (1).pdfPD ARRAY THEORY FOR INTERMEDIATE (1).pdf
PD ARRAY THEORY FOR INTERMEDIATE (1).pdf
 
is it possible to sell pi network coin in 2024.
is it possible to sell pi network coin in 2024.is it possible to sell pi network coin in 2024.
is it possible to sell pi network coin in 2024.
 
how can I sell/buy bulk pi coins securely
how can I sell/buy bulk pi coins securelyhow can I sell/buy bulk pi coins securely
how can I sell/buy bulk pi coins securely
 
The new type of smart, sustainable entrepreneurship and the next day | Europe...
The new type of smart, sustainable entrepreneurship and the next day | Europe...The new type of smart, sustainable entrepreneurship and the next day | Europe...
The new type of smart, sustainable entrepreneurship and the next day | Europe...
 
how can I sell my locked pi coins safety.
how can I sell my locked pi coins safety.how can I sell my locked pi coins safety.
how can I sell my locked pi coins safety.
 
Latino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino CaucusLatino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino Caucus
 
Juspay Case study(Doubling Revenue Juspay's Success).pptx
Juspay Case study(Doubling Revenue Juspay's Success).pptxJuspay Case study(Doubling Revenue Juspay's Success).pptx
Juspay Case study(Doubling Revenue Juspay's Success).pptx
 
Greek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business ReviewGreek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business Review
 
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理
一比一原版BCU毕业证伯明翰城市大学毕业证成绩单如何办理
 
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理
一比一原版Adelaide毕业证阿德莱德大学毕业证成绩单如何办理
 
what is the best method to sell pi coins in 2024
what is the best method to sell pi coins in 2024what is the best method to sell pi coins in 2024
what is the best method to sell pi coins in 2024
 
how can I sell pi coins after successfully completing KYC
how can I sell pi coins after successfully completing KYChow can I sell pi coins after successfully completing KYC
how can I sell pi coins after successfully completing KYC
 
how can I sell my pi coins in China 2024.
how can I sell my pi coins in China 2024.how can I sell my pi coins in China 2024.
how can I sell my pi coins in China 2024.
 
Isios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdfIsios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdf
 
Webinar Exploring DORA for Fintechs - Simont Braun
Webinar Exploring DORA for Fintechs - Simont BraunWebinar Exploring DORA for Fintechs - Simont Braun
Webinar Exploring DORA for Fintechs - Simont Braun
 
9th issue of our inhouse magazine Ingenious May 2024.pdf
9th issue of our inhouse magazine Ingenious May 2024.pdf9th issue of our inhouse magazine Ingenious May 2024.pdf
9th issue of our inhouse magazine Ingenious May 2024.pdf
 
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理一比一原版UO毕业证渥太华大学毕业证成绩单如何办理
一比一原版UO毕业证渥太华大学毕业证成绩单如何办理
 
how can i make money selling pi coins in 2024
how can i make money selling pi coins in 2024how can i make money selling pi coins in 2024
how can i make money selling pi coins in 2024
 
Introduction to Economics II Chapter 25 Production and Growth.pdf
Introduction to Economics II Chapter 25 Production and Growth.pdfIntroduction to Economics II Chapter 25 Production and Growth.pdf
Introduction to Economics II Chapter 25 Production and Growth.pdf
 
how can I transfer pi coins to someone in a different country.
how can I transfer pi coins to someone in a different country.how can I transfer pi coins to someone in a different country.
how can I transfer pi coins to someone in a different country.
 

Pwning Your Phone with Adhearsion and Asterisk

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Dave Troy’s Asterisk-Powered Roomba Dave’s also writing “Telephony with Ruby”. Will be published by The Prags in November
  • 7.
  • 8.
  • 9. Old Dialplan Example [macro-dial-iax] exten => s,1,SetGlobalVar(FOUNDME=ANSWER) exten => s,2,GotoIf($[${LEN(${ARG1})} = 10]?2:4) exten => s,3,SetVar(NumToDial=1${ARG1}) exten => s,4,Goto(s,6) exten => s,5,SetVar(NumToDial=${ARG1}) ... From extensions.conf
  • 10.
  • 13.
  • 15.
  • 16. Installing Adhearsion gem install adhearsion [asterisk-context] exten => _.,1,AGI(agi://127.0.0.1)
  • 18. Writing Adhearsion Dialplans internal { play ‘hello-world’ }
  • 19. Writing Adhearsion Dialplans internal { loop { play ‘tt-monkeys’ } }
  • 20. Writing Adhearsion Dialplans internal { +foo } foo { record { dial SIP/:out_trunk/1234 } }
  • 21. Writing Adhearsion Dialplans internal { play %w”a-connect-charge-of 16 cents-per-minute will-apply” }
  • 22. Writing Adhearsion Dialplans internal { case extension when 10 ... 100 dial SIP /extension when 6000 ... 6020 , 7000 .. 7030 join extension when _ ' 21XX ' if Time .now.hour.between? 2 , 10 dial SIP / &quot; berlin-office &quot; /extension[ 2 .. 4 ] else speak &quot; It is not business hours now in Germany. &quot; end ...
  • 23. Writing Adhearsion Dialplans ... when US_NUMBER dial SIP / ' us-trunk-out ' /extension when / ^ {11,}$ / dial IAX / ' intl-trunk-out ' /extension else play %w' sorry invalid extension please-try-again ' end }
  • 24. Database-Driven Dialplans Dialplans service { customer = Account.find_by_phone_number callerid usage = customer.usage_this_month if usage >= 100.hours then +beyond_limit else customer.usage_this_month += time do dial IAX2/'main-trunk'/extension end end } beyond_limit { play %w&quot;sorry your-limit-of 100 hours has-been-reached&quot; }
  • 25.
  • 26.
  • 28.
  • 29. Helpers require &quot;hpricot&quot; require &quot;open-uri&quot; def lookup number hash = {} url = &quot; http://www.whitepages.com/9901/search/ReversePhone?phone=#{number} &quot; doc = Hpricot open(url) # This div contains all the information we need, unless it's an unlisted number if (results = doc.at &quot;#results_single_listing&quot;) then # This div's h3 contains the name of the caller hash[:first_name], hash[:last_name] = results.at('h3').inner_html.split(/,*/).reverse # Now we just need the rest of the information contained in p's. meta = results/'p' meta.pop # Discard the useless p element hash[:number] = meta.pop.inner_html city_info = meta.pop.inner_html city_info = city_info.match /(.+), ([A-Za-z]{2}) ({5})/ hash[:city] = city_info[1] hash[:state] = city_info[2] hash[:zip] = city_info[3] hash[:address] = meta.map(&:inner_html) * &quot; &quot; elsif (results = doc.at &quot;#results_single_phone_info&quot;) then meta = results/'span' hash[:location] = (meta.pop.inner_html.match /Location: (.*)/)[1] end if hash[:first_name] or hash[:last_name] then hash[:composite] = &quot;#{hash[:first_name]} #{hash[:last_name]}&quot; else hash[:composite] = hash[:location] end hash end
  • 30. Helpers (in C) (in C) int fast_factorial(int input) { int prod = 1, count = 1; while(count <= input) { prod *= count++; } return sum; }
  • 32.
  • 33. Micromenus item 'Adhearsion Server Statistics' do item 'View Registered SIP Users' do PBX.sip_users.each do |u| item &quot;SIP user '#{u.username}' on IP #{u.ip}&quot; end end item 'View System Uptime' do item `uptime` end item 'Network' do heading 'Network Interface Info' `ifconfig eth1`.each_line do |line| item line end end end
  • 34. Micromenus item 'Call an Employee' do item 'Select an employee below.' User.find(:all).each do |user| call user.extension, user.name end end call 'Join main conference' do play 'welcome' join 5555 end
  • 35.
  • 36.