SlideShare a Scribd company logo
1
Using ARI and AGI
to Connect Asterisk Instances
in a Large Scale Environment
2
Using ARI and AGI 3
Jöran Vinzens
sipgate
VoIP developer
11 years at sipgate
>20 years in VoIP
Using ARI and AGI 4
What is this talk about?
Using ARI and AGI 5
Architecture!
not so much about code
Using ARI and AGI 6
Agenda 01 Basics
02 AGI vs ARI
03 Why ARI
04 How to interact
05 Call Handling with
multiple Instances
06 Random Tips and
Tricks
Using ARI and AGI 7
Basics
Start at the beginning
Using ARI and AGI 8
Basics
Start at the beginning
PBX
Alice
Bob
Charli
e
Ed David
Trunk Carrier
Using ARI and AGI 9
Start at the beginning
Basics
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
Kamailio
Kamailio
Carrier
Using ARI and AGI 10
Start at the beginning
Basics
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
Kamailio
Kamailio
Carrier
Using ARI and AGI 11
Basics
Start at the beginning
Dialplan
extensions.conf
Using ARI and AGI 12
Basics
Asterisk dialplan
exten = 10,1,Log(INFO, Hello World)
Using ARI and AGI 13
Basics
Asterisk dialplan
exten = 10,1,Log(INFO, Hello World)
extension
priority
application
parameter
Using ARI and AGI 14
Basics
Asterisk dialplan
exten = 10,1,Log(INFO, Hello World)
same = n,Answer()
same = n,Playback(tt-monkeys)
same = n,Hangup()
Using ARI and AGI 15
Basics
Asterisk dialplan
exten = _XN.,1,Dial(PJSIP/${EXTEN}@trunk-out,120tr)
Using ARI and AGI 16
Basics
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Application_Dial
Using ARI and AGI 17
Basics
Asterisk dialplan
there are never enough features
Using ARI and AGI 18
Basics
Asterisk dialplan
AGI
ARI
AMI
Using ARI and AGI 19
AGI vs ARI
Asterisk dialplan
AGI
Asterisk Gateway Interface
ARI
Asterisk REST Interface
Using ARI and AGI 20
AGI vs ARI
What is that?
Using ARI and AGI 21
AGI vs ARI
AGI / FastAGI
Trigger external script
Query external service
Using ARI and AGI 22
AGI vs ARI
AGI
"AGI is analogous to CGI in Apache. AGI provides an interface between the Asterisk dialplan and an external
program that wants to manipulate a channel in the dialplan. In general, the interface is synchronous - actions
taken on a channel from an AGI block and do not return until the action is completed."
https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589
Using ARI and AGI 23
AGI vs ARI
AGI
Use Cases?
Using ARI and AGI 24
AGI vs ARI
AGI use cases
DB lookups
LCR lookup
External accounting
Using ARI and AGI 25
AGI vs ARI
Asterisk dialplan
exten = _XN.,1,AGI(someLogic.agi)
exten = _XN.,1,AGI(agi://1.2.3.4:1234/entrypoint)
Using ARI and AGI 26
AGI vs ARI
AGI
● Dialplan application
● Only when dialplan is processed
● Blocks Dialplan
● No control during call
Using ARI and AGI 27
AGI vs ARI
ARI
Websocket / REST Interface
Using ARI and AGI 28
AGI vs ARI
ARI
"ARI is an asynchronous API that allows developers to build communications applications by exposing the raw primitive objects in
Asterisk - channels, bridges, endpoints, media, etc. - through an intuitive REST interface."
https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573
Using ARI and AGI 29
AGI vs ARI
Asterisk dialplan
exten = _XN.,1,Stasis(myStasisApp)
Using ARI and AGI 30
AGI vs ARI
JSON
{
"application":"hello-world",
"type":"StasisStart",
"timestamp":"2014-05-20T13:15:27.131-0500",
"args":[],
"channel":{
"id":"1400609726.3",
"state":"Up",
"name":"PJSIP/1000-00000001",
"caller":{
"name":"",
"number":""},
"connected":{
"name":"",
"number":""},
"accountcode":"",
"dialplan":{
"context":"default",
"exten":"1000",
"priority":1},
"creationtime":"2014-05-20T13:15:26.628-0500"}
}
Using ARI and AGI 31
AGI vs ARI
ARI
● Basic building blocks
● Blocks Dialplan
● JSON
Using ARI and AGI 32
AGI vs ARI
ARI building blocks
● Channels
● Bridges
● Playbacks
● Recordings
● ...
Using ARI and AGI 33
AGI vs ARI
ARI building blocks
Channel Channel
Bridge
Using ARI and AGI 34
ARI building blocks
AGI vs ARI
Channel Channel
Bridge
Asterisk
Alice Bob
SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel
Using ARI and AGI 35
AGI vs ARI
ARI
1. PJSIP channel incoming Invite
2. Dialplan App Stasis() -> StasisStart
3. REST POST bridge create
4. REST POST channel create
5. REST POST bridge add both channels
6. REST POST channel dial
7. PJSIP channel outgoing Invite
Using ARI and AGI 36
AGI vs ARI
ARI
● More work than dialplan
● More components than asterisk only
● Yet another API to learn
● ...
Why should one do that?
Using ARI and AGI 37
AGI vs ARI
ARI
Flexibility
Using ARI and AGI 38
How to interact
AGI and ARI
Why use both?
Using ARI and AGI 39
How to interact
AGI and ARI
e.g.
select Stasis App in AGI
Using ARI and AGI 40
How to interact
AGI and ARI
exten = _XN.,1,Agi(selectStasisApp.agi)
same = n,Log(NOTICE, AGI selected ARI App: ${STASISAPP})
same = n,Stasis(${STASISAPP})
Using ARI and AGI 41
ARI primitive objects
AGI vs ARI
Dialplan Channel
Asterisk
Alice Bob
SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel
AGI ARI
Bridge
Using ARI and AGI 42
How to interact
AGI and ARI
What if we want to call an AGI on a ARI
initiated call?
Using ARI and AGI 43
ARI primitive objects
AGI vs ARI
Channel -> Dialplan Channel
Asterisk
Alice Bob
SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel
AGI ARI
Bridge
AGI
Using ARI and AGI 44
How to interact
AGI and ARI
The magic of Local Channel
Using ARI and AGI 45
How to interact
What is a local Channel?
Channel Channel
app_dial
Asterisk
Alice Bob
PJSIP Channel PJSIP Channel
Using ARI and AGI 46
How to interact
What is a local Channel?
Channel Channel
app_dial
Asterisk
Alice Bob
PJSIP Channel PJSIP Channel
app_dial
Channel
Local Channel
Using ARI and AGI 47
How to interact
How to use local Channels with Stasis?
Channel Channel
app_dial
Asterisk
Alice Bob
PJSIP Channel PJSIP Channel
app_dial
Channel
Local Channel
Using ARI and AGI 48
How to interact
How to use local Channels with Stasis?
Channel Channel
app_stasis
Asterisk
Alice Bob
PJSIP Channel PJSIP Channel
app_dial
Channel
Local Channel
Using ARI and AGI 49
How to interact
How to use local Channels with Stasis?
Channel Channel
app_stasis
Asterisk
Alice Bob
PJSIP Channel PJSIP Channel
app_dial
Channel
Local Channel
AGI AGI
Using ARI and AGI 50
How to interact
AGI and ARI
Alice AGI
Stasis
Dial
AGI
determine Stasis App
control over the entire call
place Local Channel
Check Wholesale Carrier (LCR)
place call
Carrier
Using ARI and AGI 51
Call handling with multiple Instances
Connect Asterisk instances?
Using ARI and AGI 52
Call handling with multiple Instances
Connect Asterisk instances?
First, a scenario
Using ARI and AGI 53
Call handling with multiple Instances
Connect Asterisk instances?
First, a scenario
Pickup a call!
Using ARI and AGI 54
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
Using ARI and AGI 55
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
Using ARI and AGI 56
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
Using ARI and AGI 57
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
AGI
What Stasis App?
Using ARI and AGI 58
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
AGI
What Stasis App?
Using ARI and AGI 59
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
AGI
What Stasis App?
Using ARI and AGI 60
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
AGI
What Stasis App?
Using ARI and AGI 61
Call handling with multiple Instances
Drawbacks
● Complex call routing
● Nothing for free from Asterisk
● Yet another API
● Shared knowledge over instances
Using ARI and AGI 62
Call handling with multiple Instances
Benefits
● Scaling
● Reduce fallout on crash
● REST / Websocket
● Enforced boundaries
Using ARI and AGI 63
Call handling with multiple Instances
Drawbacks
Single point of Failure
Using ARI and AGI 64
Call handling with multiple Instances
Kamailio
Alice
Bob
Charlie
Asterisk
Asterisk
Asterisk
Asterisk
Carrier
Kamailio
AGI
What Stasis App?
ARI
Call control
AGI
What Stasis App?
Using ARI and AGI 65
Call handling with multiple Instances
Asterisk
Asterisk
Asterisk
Asterisk
ARI
ARI
ARI
ARI
Using ARI and AGI 66
Call handling with multiple Instances
Asterisk
Asterisk
Asterisk
Asterisk
ARI
ARI
Use an ARI Proxy
Kafka / RabbitMQ / NATS
ARI
Proxy
ARI
Proxy
ARI
Proxy
ARI
Proxy
Using ARI and AGI 67
Call handling with multiple Instances
Asterisk
Asterisk
Asterisk
Asterisk
ARI
ARI
Use an ARI Proxy
Kafka / RabbitMQ / NATS
ARI
Proxy
ARI
Proxy
ARI
Proxy
ARI
Proxy
Control callflow ARI connection
Using ARI and AGI 68
Call handling with multiple Instances
ARI Proxy
CyCoreSystems
https://github.com/CyCoreSystems/ari-proxy - NATS / RabbitMQ
retel-io
https://github.com/retel-io/ari-proxy - Kafka
(Kafka sample https://github.com/vinzens81/ari-controller)
Using ARI and AGI 69
Call handling with multiple Instances
Nice picture here!
Questions?
70
Jöran Vinzens
@vinzens81
linkedin.com/in/jvinzens/

More Related Content

What's hot

SIPREC RTPEngine Media Forking
SIPREC RTPEngine Media ForkingSIPREC RTPEngine Media Forking
SIPREC RTPEngine Media Forking
Hossein Yavari
 
Using Kamailio for Scalability and Security
Using Kamailio for Scalability and SecurityUsing Kamailio for Scalability and Security
Using Kamailio for Scalability and Security
Fred Posner
 
SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)
Fred Posner
 
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat
 
Asterisk High Availability Design Guide
Asterisk High Availability Design GuideAsterisk High Availability Design Guide
Asterisk High Availability Design Guide
Michelle Dupuis
 
Kamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load BalancersKamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load Balancers
Daniel-Constantin Mierla
 
Asterisk sip channel performance
Asterisk sip channel performanceAsterisk sip channel performance
Asterisk sip channel performance
Flavio Eduardo de Andrade Goncalves
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
Moises Silva
 
High Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft AzureHigh Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft Azure
Sanjay Willie
 
Podman Overview and internals.pdf
Podman Overview and internals.pdfPodman Overview and internals.pdf
Podman Overview and internals.pdf
Saim Safder
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
建澄 吳
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS
Akihiro Suda
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and Kubernetes
Paolo Visintin
 
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH DeploymentThree Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Fred Posner
 
Continuous Integration and Kamailio
Continuous Integration and KamailioContinuous Integration and Kamailio
Continuous Integration and Kamailio
Giacomo Vacca
 
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus GatewayAsterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
Alessandro Polidori
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with Go
Digium
 
Kamailio, FreeSWITCH, and You
Kamailio, FreeSWITCH, and YouKamailio, FreeSWITCH, and You
Kamailio, FreeSWITCH, and You
Fred Posner
 
FreeSWITCH Cluster by K8s
FreeSWITCH Cluster by K8sFreeSWITCH Cluster by K8s
FreeSWITCH Cluster by K8s
Chien Cheng Wu
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installations
Olle E Johansson
 

What's hot (20)

SIPREC RTPEngine Media Forking
SIPREC RTPEngine Media ForkingSIPREC RTPEngine Media Forking
SIPREC RTPEngine Media Forking
 
Using Kamailio for Scalability and Security
Using Kamailio for Scalability and SecurityUsing Kamailio for Scalability and Security
Using Kamailio for Scalability and Security
 
SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)SIP Attack Handling (Kamailio World 2021)
SIP Attack Handling (Kamailio World 2021)
 
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
 
Asterisk High Availability Design Guide
Asterisk High Availability Design GuideAsterisk High Availability Design Guide
Asterisk High Availability Design Guide
 
Kamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load BalancersKamailio - Load Balancing Load Balancers
Kamailio - Load Balancing Load Balancers
 
Asterisk sip channel performance
Asterisk sip channel performanceAsterisk sip channel performance
Asterisk sip channel performance
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
 
High Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft AzureHigh Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft Azure
 
Podman Overview and internals.pdf
Podman Overview and internals.pdfPodman Overview and internals.pdf
Podman Overview and internals.pdf
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS
 
Kamailio with Docker and Kubernetes
Kamailio with Docker and KubernetesKamailio with Docker and Kubernetes
Kamailio with Docker and Kubernetes
 
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH DeploymentThree Ways Kamailio Can Help Your FreeSWITCH Deployment
Three Ways Kamailio Can Help Your FreeSWITCH Deployment
 
Continuous Integration and Kamailio
Continuous Integration and KamailioContinuous Integration and Kamailio
Continuous Integration and Kamailio
 
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus GatewayAsterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: realize client SIP Phone with sipML5 and Janus Gateway
 
Scaling FastAGI Applications with Go
Scaling FastAGI Applications with GoScaling FastAGI Applications with Go
Scaling FastAGI Applications with Go
 
Kamailio, FreeSWITCH, and You
Kamailio, FreeSWITCH, and YouKamailio, FreeSWITCH, and You
Kamailio, FreeSWITCH, and You
 
FreeSWITCH Cluster by K8s
FreeSWITCH Cluster by K8sFreeSWITCH Cluster by K8s
FreeSWITCH Cluster by K8s
 
Astricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installationsAstricon 2010: Scaling Asterisk installations
Astricon 2010: Scaling Asterisk installations
 

More from Jöran Vinzens

Integrate POTS Carrier grade PBX to AI and WebRTC
Integrate POTS Carrier grade PBX to AI and WebRTCIntegrate POTS Carrier grade PBX to AI and WebRTC
Integrate POTS Carrier grade PBX to AI and WebRTC
Jöran Vinzens
 
Astricon plan 9 2020
Astricon plan 9 2020Astricon plan 9 2020
Astricon plan 9 2020
Jöran Vinzens
 
Asterisk 11to16, What could go wrong
Asterisk 11to16, What could go wrongAsterisk 11to16, What could go wrong
Asterisk 11to16, What could go wrong
Jöran Vinzens
 
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
Jöran Vinzens
 
astricon2018
astricon2018astricon2018
astricon2018
Jöran Vinzens
 
Commcon 2018
Commcon 2018Commcon 2018
Commcon 2018
Jöran Vinzens
 
Astricon 2015
Astricon 2015Astricon 2015
Astricon 2015
Jöran Vinzens
 
Ss7 isup homer
Ss7 isup homerSs7 isup homer
Ss7 isup homer
Jöran Vinzens
 
Astricon 2016
Astricon 2016Astricon 2016
Astricon 2016
Jöran Vinzens
 
Astricon 2017 Superpower of deployment tools
Astricon 2017 Superpower of deployment toolsAstricon 2017 Superpower of deployment tools
Astricon 2017 Superpower of deployment tools
Jöran Vinzens
 

More from Jöran Vinzens (10)

Integrate POTS Carrier grade PBX to AI and WebRTC
Integrate POTS Carrier grade PBX to AI and WebRTCIntegrate POTS Carrier grade PBX to AI and WebRTC
Integrate POTS Carrier grade PBX to AI and WebRTC
 
Astricon plan 9 2020
Astricon plan 9 2020Astricon plan 9 2020
Astricon plan 9 2020
 
Asterisk 11to16, What could go wrong
Asterisk 11to16, What could go wrongAsterisk 11to16, What could go wrong
Asterisk 11to16, What could go wrong
 
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
SITREP - Asterisk REST. The first steps are done, now what? - CommCon 2019
 
astricon2018
astricon2018astricon2018
astricon2018
 
Commcon 2018
Commcon 2018Commcon 2018
Commcon 2018
 
Astricon 2015
Astricon 2015Astricon 2015
Astricon 2015
 
Ss7 isup homer
Ss7 isup homerSs7 isup homer
Ss7 isup homer
 
Astricon 2016
Astricon 2016Astricon 2016
Astricon 2016
 
Astricon 2017 Superpower of deployment tools
Astricon 2017 Superpower of deployment toolsAstricon 2017 Superpower of deployment tools
Astricon 2017 Superpower of deployment tools
 

Recently uploaded

2023 Ukraine Crisis Media Center Financial Report
2023 Ukraine Crisis Media Center Financial Report2023 Ukraine Crisis Media Center Financial Report
2023 Ukraine Crisis Media Center Financial Report
UkraineCrisisMediaCenter
 
Legislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptxLegislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptx
Charmi13
 
SASi-SPi Science Policy Lab Pre-engagement
SASi-SPi Science Policy Lab Pre-engagementSASi-SPi Science Policy Lab Pre-engagement
SASi-SPi Science Policy Lab Pre-engagement
Francois Stepman
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
SkillCertProExams
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
kainatfatyma9
 
Bridging the visual gap between cultural heritage and digital scholarship
Bridging the visual gap between cultural heritage and digital scholarshipBridging the visual gap between cultural heritage and digital scholarship
Bridging the visual gap between cultural heritage and digital scholarship
Inesm9
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
OECD Directorate for Financial and Enterprise Affairs
 
2023 Ukraine Crisis Media Center Annual Report
2023 Ukraine Crisis Media Center Annual Report2023 Ukraine Crisis Media Center Annual Report
2023 Ukraine Crisis Media Center Annual Report
UkraineCrisisMediaCenter
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
Data Processing in PHP - PHPers 2024 Poznań
Data Processing in PHP - PHPers 2024 PoznańData Processing in PHP - PHPers 2024 Poznań
Data Processing in PHP - PHPers 2024 Poznań
Norbert Orzechowicz
 
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPEACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
Charmi13
 
Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
Raheem Muhammad
 
AWS User Group Torino 2024 #3 - 18/06/2024
AWS User Group Torino 2024 #3 - 18/06/2024AWS User Group Torino 2024 #3 - 18/06/2024
AWS User Group Torino 2024 #3 - 18/06/2024
Guido Maria Nebiolo
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
kekzed
 
Genesis chapter 3 Isaiah Scudder.pptx
Genesis    chapter 3 Isaiah Scudder.pptxGenesis    chapter 3 Isaiah Scudder.pptx
Genesis chapter 3 Isaiah Scudder.pptx
FamilyWorshipCenterD
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
Ben Linders
 
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
gfysze
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
2023 Ukraine Crisis Media Center Finance Balance
2023 Ukraine Crisis Media Center Finance Balance2023 Ukraine Crisis Media Center Finance Balance
2023 Ukraine Crisis Media Center Finance Balance
UkraineCrisisMediaCenter
 
2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates
UAE Ppt
 

Recently uploaded (20)

2023 Ukraine Crisis Media Center Financial Report
2023 Ukraine Crisis Media Center Financial Report2023 Ukraine Crisis Media Center Financial Report
2023 Ukraine Crisis Media Center Financial Report
 
Legislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptxLegislation And Regulations For Import, Manufacture,.pptx
Legislation And Regulations For Import, Manufacture,.pptx
 
SASi-SPi Science Policy Lab Pre-engagement
SASi-SPi Science Policy Lab Pre-engagementSASi-SPi Science Policy Lab Pre-engagement
SASi-SPi Science Policy Lab Pre-engagement
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
 
Bridging the visual gap between cultural heritage and digital scholarship
Bridging the visual gap between cultural heritage and digital scholarshipBridging the visual gap between cultural heritage and digital scholarship
Bridging the visual gap between cultural heritage and digital scholarship
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
 
2023 Ukraine Crisis Media Center Annual Report
2023 Ukraine Crisis Media Center Annual Report2023 Ukraine Crisis Media Center Annual Report
2023 Ukraine Crisis Media Center Annual Report
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
 
Data Processing in PHP - PHPers 2024 Poznań
Data Processing in PHP - PHPers 2024 PoznańData Processing in PHP - PHPers 2024 Poznań
Data Processing in PHP - PHPers 2024 Poznań
 
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPEACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
ACTIVE IMPLANTABLE MEDICAL DEVICE IN EUROPE
 
Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
 
AWS User Group Torino 2024 #3 - 18/06/2024
AWS User Group Torino 2024 #3 - 18/06/2024AWS User Group Torino 2024 #3 - 18/06/2024
AWS User Group Torino 2024 #3 - 18/06/2024
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
 
Genesis chapter 3 Isaiah Scudder.pptx
Genesis    chapter 3 Isaiah Scudder.pptxGenesis    chapter 3 Isaiah Scudder.pptx
Genesis chapter 3 Isaiah Scudder.pptx
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
 
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
一比一原版(unc毕业证书)美国北卡罗来纳大学教堂山分校毕业证如何办理
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
 
2023 Ukraine Crisis Media Center Finance Balance
2023 Ukraine Crisis Media Center Finance Balance2023 Ukraine Crisis Media Center Finance Balance
2023 Ukraine Crisis Media Center Finance Balance
 
2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates2 December UAE National Day - United Arab Emirates
2 December UAE National Day - United Arab Emirates
 

Using ARI and AGI to Connect Asterisk Instances

  • 1. 1
  • 2. Using ARI and AGI to Connect Asterisk Instances in a Large Scale Environment 2
  • 3. Using ARI and AGI 3 Jöran Vinzens sipgate VoIP developer 11 years at sipgate >20 years in VoIP
  • 4. Using ARI and AGI 4 What is this talk about?
  • 5. Using ARI and AGI 5 Architecture! not so much about code
  • 6. Using ARI and AGI 6 Agenda 01 Basics 02 AGI vs ARI 03 Why ARI 04 How to interact 05 Call Handling with multiple Instances 06 Random Tips and Tricks
  • 7. Using ARI and AGI 7 Basics Start at the beginning
  • 8. Using ARI and AGI 8 Basics Start at the beginning PBX Alice Bob Charli e Ed David Trunk Carrier
  • 9. Using ARI and AGI 9 Start at the beginning Basics Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio Kamailio Kamailio Carrier
  • 10. Using ARI and AGI 10 Start at the beginning Basics Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio Kamailio Kamailio Carrier
  • 11. Using ARI and AGI 11 Basics Start at the beginning Dialplan extensions.conf
  • 12. Using ARI and AGI 12 Basics Asterisk dialplan exten = 10,1,Log(INFO, Hello World)
  • 13. Using ARI and AGI 13 Basics Asterisk dialplan exten = 10,1,Log(INFO, Hello World) extension priority application parameter
  • 14. Using ARI and AGI 14 Basics Asterisk dialplan exten = 10,1,Log(INFO, Hello World) same = n,Answer() same = n,Playback(tt-monkeys) same = n,Hangup()
  • 15. Using ARI and AGI 15 Basics Asterisk dialplan exten = _XN.,1,Dial(PJSIP/${EXTEN}@trunk-out,120tr)
  • 16. Using ARI and AGI 16 Basics https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Application_Dial
  • 17. Using ARI and AGI 17 Basics Asterisk dialplan there are never enough features
  • 18. Using ARI and AGI 18 Basics Asterisk dialplan AGI ARI AMI
  • 19. Using ARI and AGI 19 AGI vs ARI Asterisk dialplan AGI Asterisk Gateway Interface ARI Asterisk REST Interface
  • 20. Using ARI and AGI 20 AGI vs ARI What is that?
  • 21. Using ARI and AGI 21 AGI vs ARI AGI / FastAGI Trigger external script Query external service
  • 22. Using ARI and AGI 22 AGI vs ARI AGI "AGI is analogous to CGI in Apache. AGI provides an interface between the Asterisk dialplan and an external program that wants to manipulate a channel in the dialplan. In general, the interface is synchronous - actions taken on a channel from an AGI block and do not return until the action is completed." https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=32375589
  • 23. Using ARI and AGI 23 AGI vs ARI AGI Use Cases?
  • 24. Using ARI and AGI 24 AGI vs ARI AGI use cases DB lookups LCR lookup External accounting
  • 25. Using ARI and AGI 25 AGI vs ARI Asterisk dialplan exten = _XN.,1,AGI(someLogic.agi) exten = _XN.,1,AGI(agi://1.2.3.4:1234/entrypoint)
  • 26. Using ARI and AGI 26 AGI vs ARI AGI ● Dialplan application ● Only when dialplan is processed ● Blocks Dialplan ● No control during call
  • 27. Using ARI and AGI 27 AGI vs ARI ARI Websocket / REST Interface
  • 28. Using ARI and AGI 28 AGI vs ARI ARI "ARI is an asynchronous API that allows developers to build communications applications by exposing the raw primitive objects in Asterisk - channels, bridges, endpoints, media, etc. - through an intuitive REST interface." https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573
  • 29. Using ARI and AGI 29 AGI vs ARI Asterisk dialplan exten = _XN.,1,Stasis(myStasisApp)
  • 30. Using ARI and AGI 30 AGI vs ARI JSON { "application":"hello-world", "type":"StasisStart", "timestamp":"2014-05-20T13:15:27.131-0500", "args":[], "channel":{ "id":"1400609726.3", "state":"Up", "name":"PJSIP/1000-00000001", "caller":{ "name":"", "number":""}, "connected":{ "name":"", "number":""}, "accountcode":"", "dialplan":{ "context":"default", "exten":"1000", "priority":1}, "creationtime":"2014-05-20T13:15:26.628-0500"} }
  • 31. Using ARI and AGI 31 AGI vs ARI ARI ● Basic building blocks ● Blocks Dialplan ● JSON
  • 32. Using ARI and AGI 32 AGI vs ARI ARI building blocks ● Channels ● Bridges ● Playbacks ● Recordings ● ...
  • 33. Using ARI and AGI 33 AGI vs ARI ARI building blocks Channel Channel Bridge
  • 34. Using ARI and AGI 34 ARI building blocks AGI vs ARI Channel Channel Bridge Asterisk Alice Bob SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel
  • 35. Using ARI and AGI 35 AGI vs ARI ARI 1. PJSIP channel incoming Invite 2. Dialplan App Stasis() -> StasisStart 3. REST POST bridge create 4. REST POST channel create 5. REST POST bridge add both channels 6. REST POST channel dial 7. PJSIP channel outgoing Invite
  • 36. Using ARI and AGI 36 AGI vs ARI ARI ● More work than dialplan ● More components than asterisk only ● Yet another API to learn ● ... Why should one do that?
  • 37. Using ARI and AGI 37 AGI vs ARI ARI Flexibility
  • 38. Using ARI and AGI 38 How to interact AGI and ARI Why use both?
  • 39. Using ARI and AGI 39 How to interact AGI and ARI e.g. select Stasis App in AGI
  • 40. Using ARI and AGI 40 How to interact AGI and ARI exten = _XN.,1,Agi(selectStasisApp.agi) same = n,Log(NOTICE, AGI selected ARI App: ${STASISAPP}) same = n,Stasis(${STASISAPP})
  • 41. Using ARI and AGI 41 ARI primitive objects AGI vs ARI Dialplan Channel Asterisk Alice Bob SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel AGI ARI Bridge
  • 42. Using ARI and AGI 42 How to interact AGI and ARI What if we want to call an AGI on a ARI initiated call?
  • 43. Using ARI and AGI 43 ARI primitive objects AGI vs ARI Channel -> Dialplan Channel Asterisk Alice Bob SIP Invite - PJSIP Channel POST ari/channels/create - PJSIP Channel AGI ARI Bridge AGI
  • 44. Using ARI and AGI 44 How to interact AGI and ARI The magic of Local Channel
  • 45. Using ARI and AGI 45 How to interact What is a local Channel? Channel Channel app_dial Asterisk Alice Bob PJSIP Channel PJSIP Channel
  • 46. Using ARI and AGI 46 How to interact What is a local Channel? Channel Channel app_dial Asterisk Alice Bob PJSIP Channel PJSIP Channel app_dial Channel Local Channel
  • 47. Using ARI and AGI 47 How to interact How to use local Channels with Stasis? Channel Channel app_dial Asterisk Alice Bob PJSIP Channel PJSIP Channel app_dial Channel Local Channel
  • 48. Using ARI and AGI 48 How to interact How to use local Channels with Stasis? Channel Channel app_stasis Asterisk Alice Bob PJSIP Channel PJSIP Channel app_dial Channel Local Channel
  • 49. Using ARI and AGI 49 How to interact How to use local Channels with Stasis? Channel Channel app_stasis Asterisk Alice Bob PJSIP Channel PJSIP Channel app_dial Channel Local Channel AGI AGI
  • 50. Using ARI and AGI 50 How to interact AGI and ARI Alice AGI Stasis Dial AGI determine Stasis App control over the entire call place Local Channel Check Wholesale Carrier (LCR) place call Carrier
  • 51. Using ARI and AGI 51 Call handling with multiple Instances Connect Asterisk instances?
  • 52. Using ARI and AGI 52 Call handling with multiple Instances Connect Asterisk instances? First, a scenario
  • 53. Using ARI and AGI 53 Call handling with multiple Instances Connect Asterisk instances? First, a scenario Pickup a call!
  • 54. Using ARI and AGI 54 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio
  • 55. Using ARI and AGI 55 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio
  • 56. Using ARI and AGI 56 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control
  • 57. Using ARI and AGI 57 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control AGI What Stasis App?
  • 58. Using ARI and AGI 58 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control AGI What Stasis App?
  • 59. Using ARI and AGI 59 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control AGI What Stasis App?
  • 60. Using ARI and AGI 60 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control AGI What Stasis App?
  • 61. Using ARI and AGI 61 Call handling with multiple Instances Drawbacks ● Complex call routing ● Nothing for free from Asterisk ● Yet another API ● Shared knowledge over instances
  • 62. Using ARI and AGI 62 Call handling with multiple Instances Benefits ● Scaling ● Reduce fallout on crash ● REST / Websocket ● Enforced boundaries
  • 63. Using ARI and AGI 63 Call handling with multiple Instances Drawbacks Single point of Failure
  • 64. Using ARI and AGI 64 Call handling with multiple Instances Kamailio Alice Bob Charlie Asterisk Asterisk Asterisk Asterisk Carrier Kamailio AGI What Stasis App? ARI Call control AGI What Stasis App?
  • 65. Using ARI and AGI 65 Call handling with multiple Instances Asterisk Asterisk Asterisk Asterisk ARI ARI ARI ARI
  • 66. Using ARI and AGI 66 Call handling with multiple Instances Asterisk Asterisk Asterisk Asterisk ARI ARI Use an ARI Proxy Kafka / RabbitMQ / NATS ARI Proxy ARI Proxy ARI Proxy ARI Proxy
  • 67. Using ARI and AGI 67 Call handling with multiple Instances Asterisk Asterisk Asterisk Asterisk ARI ARI Use an ARI Proxy Kafka / RabbitMQ / NATS ARI Proxy ARI Proxy ARI Proxy ARI Proxy Control callflow ARI connection
  • 68. Using ARI and AGI 68 Call handling with multiple Instances ARI Proxy CyCoreSystems https://github.com/CyCoreSystems/ari-proxy - NATS / RabbitMQ retel-io https://github.com/retel-io/ari-proxy - Kafka (Kafka sample https://github.com/vinzens81/ari-controller)
  • 69. Using ARI and AGI 69 Call handling with multiple Instances Nice picture here!