SlideShare a Scribd company logo
1 of 25
Asterisk, HTML5 and NodeJS;
a world of endless possibilities
            Dan Jenkins
           Astricon 2012
                                @dan_jenkins
                               @holidayextras
The next half an hour....
• Introductions

• Who Holiday Extras are

• HTML5

• What’s NodeJS

• How we’ve used NodeJS within our production environment

• Demonstration
Who am I?
                 el op er         Dan Jenkins
             D ev
           eb neer
       r W ngi                    @dan_jenkins              2 Years
S   io
  en oIP E
     &   V



                            Author of Asterisk-AMI Module
It’s in the name, we sell extras for holidays
                            We’re partners with some big names in the UK
                                                          travel industry


                    Theme Park Breaks
                                                                easyJet
                   Legoland, Alton Towers
                     to name just a few                  British Airways
                                                           Thomas Cook
                     Theatre Breaks
Since moving to Asterisk,
                                                   Over 800,000 calls through
    we’ve taken ~516,000 phone
    calls in our Contact Centre                    our Contact Centre last year

                                     We are the market leaders!
 We believe Holidays
should be Hassle Free                                We’ve been using Asterisk
                                                     in production since April
               Operate in mainland Europe
               too, with Holiday Extras DE                   We’re a 29 year old start up
Get on with it!
What’s so great about HTML5?
Easier to iterate, there’s millions of
    web developers out there                No extra plugins required!


            Faster time to launch
                                         Over 60% of users with Internet
                                           access have browsers that
     Make fully featured apps                   suppport HTML5
      direct in the browser
What can you do with HTML5?
                                Client-side databases
 Get User Media
(Microphone & Video)                                    Offline Application cache

                                Web workers
                                 (Threads)
           WebRTC                                        Two way, real-time,
   (SIP phone in the browser)                              communication
So, what’s NodeJS?


“Node.js uses an event-driven, non-blocking I/O model that
makes it lightweight and efficient, perfect for data-intensive
real-time applications that run across distributed devices.”
What have Holiday Extras done?
     Integrated control of the call directly into our in-house CRM
   system, this also allows us to look up our customer in realtime

We’ve been through about 3 iterations of the integration
NodeJS and HTML5 have given us the ability to do this
We are able to move fast to react to the current needs of our business
How does it all fit together?
            NodeJS
                                                      Asterisk
            Server




Web Sockets
Asterisk-AMI TCP Socket
SIP                       Chrome   Firefox   Safari
                           + SF     + SF     + SF
Now for the demo


                    @dan_jenkins
                   @holidayextras
Firstly, install the module

                                npm install asterisk-ami



Prerequisite: install NodeJS first!
Create a basic NodeJS server

 Output a ping response from Asterisk in the
    command line, from the NodeJS app
server.js
var AsteriskAmi = require('asterisk-ami');
var ami = new AsteriskAmi( { host: '172.16.172.130', username: 'astricon', password:
'secret' } );

ami.on('ami_data', function(data){
  console.log('AMI DATA', data);
});

ami.connect(function(response){
  console.log('connected to the AMI');
  setInterval(function(){
    ami.send({action: 'Ping'});//run a callback event when we have connected to the socket
  }, 2000);
});

process.on('SIGINT', function () {
  ami.disconnect();
" process.exit(0);
});



                           github.com/danjenkins/astricon-2012
Time to step it up a notch,
let’s make it output to a webpage
       Output that same ping response
         to a browser, using NodeJS
server.js
var   AsteriskAmi = require('asterisk-ami');
var   nowjs = require("now");
var   fs = require('fs');
var   express = require('express');
var   http = require('http');

var ami = new AsteriskAmi( { host: '172.16.172.130', username: 'astricon',
password: 'secret' } );
var app = express();
var server = http.createServer(app).listen(8080, function(){
  console.log('listening on http://localhost:8080');
});

app.configure(function(){
  app.use("/assets", express.static(__dirname + '/assets'));
});


                         github.com/danjenkins/astricon-2012
app.use(express.errorHandler());
app.get('/', function(req, res) {
  var stream = fs.createReadStream(__dirname + '/webpage.html');
  stream.on('error', function (err) {
      res.statusCode = 500;
      res.end(String(err));
  });
  stream.pipe(res);
})

var everyone = nowjs.initialize(server);

ami.on('ami_data', function(data){
  if(everyone.now.echoAsteriskData instanceof Function){
    everyone.now.echoAsteriskData(data);
  }
});


                       github.com/danjenkins/astricon-2012
ami.connect(function(response){
  console.log('connected to the AMI');
  setInterval(function(){
    ami.send({action: 'Ping'});//run a callback event when we have connected to
the socket
  }, 2000);
});

process.on('SIGINT', function () {
  ami.disconnect();
  process.exit(0);
});




                       github.com/danjenkins/astricon-2012
webpage.html
<script type="text/javascript" src="/nowjs/now.js"></script>

<script type="text/javascript">
  var output = function(data){
  var html = '<div>' + (data instanceof Object ? JSON.stringify(data) : data) + '</div>';
  var div = document.getElementById('output');
   div.innerHTML = html + div.innerHTML;
  }

  now.echoAsteriskData = function(data){
   output(data);
  }

  now.ready(function(){
    output('connected via nowjs');
  });
</script>




                           github.com/danjenkins/astricon-2012
Now, let’s create a call from the webpage
   via Bria - Asterisk 11 - SIP Phone
     Let’s make the browser do something, make it create
              a call between two sip extensions
server.js

+everyone.now.send_data_to_asterisk = function(data){
+  console.log('got data from browser', data);
+  ami.send(data);
+}




                           github.com/danjenkins/astricon-2012
webpage.html

$('.btn').click(function(e){
   var obj = {};
  if($(this).is('.help')){
   obj = {action: 'ListCommands'};
  }else if($(this).is('.reload')){
    obj = {action: 'reload'};
  }else if($(this).is('.login')){
    obj = {action: 'QueueAdd', queue: '10', interface: 'sip/2000', penalty: 1, paused:
true};
  }else if($(this).is('.unpause')){
    obj = {action: 'QueuePause', queue: '10', interface: 'sip/2000', paused: false};
  }else if($(this).is('.dial')){
    obj = { action: 'originate', channel: 'SIP/1000', exten: 10, context: 'from-internal',
priority : 1, async: true, callerid: '1000 VIA AMI "1000"' };
  }else if($(this).is('.logout')){
   obj = {action: 'QueueRemove', queue: '10', interface: 'sip/2000'};
  }
  now.send_data_to_asterisk(obj);
   e.preventDefault();
})


                           github.com/danjenkins/astricon-2012
Questions?
Thank You!
Dan Jenkins
     @dan_jenkins
                            Astricon 2012
                      dan.jenkins@holidayextras.com
                      hungrygeek.holidayextras.co.uk

                           npm.im/asterisk-ami
                github.com/holidayextras/node-asterisk-ami

More Related Content

What's hot

Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesGanesh Samarthyam
 
One Neos CMS - many websites
One Neos CMS - many websitesOne Neos CMS - many websites
One Neos CMS - many websitespunkt.de GmbH
 
Spring cheat sheet
Spring cheat sheetSpring cheat sheet
Spring cheat sheetMark Papis
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
Reactjs workshop (1)
Reactjs workshop (1)Reactjs workshop (1)
Reactjs workshop (1)Ahmed rebai
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash CourseHaim Michael
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterSimen Li
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programmingRodolfo Finochietti
 
An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...Claudio Capobianco
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Patrycja Wegrzynowicz
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfJosé Paumard
 
Management des vulnérabilités - Greenbone OpenVas
Management des vulnérabilités - Greenbone OpenVasManagement des vulnérabilités - Greenbone OpenVas
Management des vulnérabilités - Greenbone OpenVasEyesOpen Association
 
Node js overview
Node js overviewNode js overview
Node js overviewEyal Vardi
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?Andrei Pangin
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascriptEman Mohamed
 
Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With XtextSven Efftinge
 

What's hot (20)

Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional Interfaces
 
One Neos CMS - many websites
One Neos CMS - many websitesOne Neos CMS - many websites
One Neos CMS - many websites
 
Spring cheat sheet
Spring cheat sheetSpring cheat sheet
Spring cheat sheet
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Introduction to Rust
Introduction to RustIntroduction to Rust
Introduction to Rust
 
Reactjs workshop (1)
Reactjs workshop (1)Reactjs workshop (1)
Reactjs workshop (1)
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash Course
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitter
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programming
 
An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...
 
Monadic Java
Monadic JavaMonadic Java
Monadic Java
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdf
 
Management des vulnérabilités - Greenbone OpenVas
Management des vulnérabilités - Greenbone OpenVasManagement des vulnérabilités - Greenbone OpenVas
Management des vulnérabilités - Greenbone OpenVas
 
Node js overview
Node js overviewNode js overview
Node js overview
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
 
Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With Xtext
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 

Viewers also liked

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
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskMoises Silva
 
WebRTC & Asterisk 11
WebRTC & Asterisk 11WebRTC & Asterisk 11
WebRTC & Asterisk 11Sanjay Willie
 
Getting physical with web bluetooth in the browser hackference
Getting physical with web bluetooth in the browser hackferenceGetting physical with web bluetooth in the browser hackference
Getting physical with web bluetooth in the browser hackferenceDan Jenkins
 
WebRTC From Asterisk to Headline - MoNage
WebRTC From Asterisk to Headline - MoNageWebRTC From Asterisk to Headline - MoNage
WebRTC From Asterisk to Headline - MoNageChad Hart
 
6 Months with WebRTC
6 Months with WebRTC6 Months with WebRTC
6 Months with WebRTCArin Sime
 
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)Victor Pascual Ávila
 
AstriCon 2015: WebRTC: How it Works, and How it Breaks
AstriCon 2015: WebRTC: How it Works, and How it BreaksAstriCon 2015: WebRTC: How it Works, and How it Breaks
AstriCon 2015: WebRTC: How it Works, and How it BreaksMojo Lingo
 
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...Nome Sobrenome
 
Exploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTCExploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTCGrgur Grisogono
 
How to set your ADI business profile
How to set your ADI business profileHow to set your ADI business profile
How to set your ADI business profileRoadio
 
Get to know Holiday Extras 2011
Get to know Holiday Extras 2011Get to know Holiday Extras 2011
Get to know Holiday Extras 2011Matthew Pack
 
Apache Cordova, Hybrid Application Development
Apache Cordova, Hybrid Application DevelopmentApache Cordova, Hybrid Application Development
Apache Cordova, Hybrid Application Developmentthedumbterminal
 
Exploring Open Date with BigQuery: Jenny Tong
Exploring Open Date with BigQuery: Jenny TongExploring Open Date with BigQuery: Jenny Tong
Exploring Open Date with BigQuery: Jenny TongFuture Insights
 
Scottish Communicators Network - 22 October 2014 - People Make Glasgow
Scottish Communicators Network - 22 October 2014 - People Make GlasgowScottish Communicators Network - 22 October 2014 - People Make Glasgow
Scottish Communicators Network - 22 October 2014 - People Make GlasgowJane Robson
 
Polyglot polywhat polywhy
Polyglot polywhat polywhyPolyglot polywhat polywhy
Polyglot polywhat polywhythedumbterminal
 
How to get started with Roadio in under 60 seconds
How to get started with Roadio in under 60 secondsHow to get started with Roadio in under 60 seconds
How to get started with Roadio in under 60 secondsRoadio
 

Viewers also liked (20)

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
 
Implementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in AsteriskImplementation Lessons using WebRTC in Asterisk
Implementation Lessons using WebRTC in Asterisk
 
WebRTC & Asterisk 11
WebRTC & Asterisk 11WebRTC & Asterisk 11
WebRTC & Asterisk 11
 
Getting physical with web bluetooth in the browser hackference
Getting physical with web bluetooth in the browser hackferenceGetting physical with web bluetooth in the browser hackference
Getting physical with web bluetooth in the browser hackference
 
WebRTC From Asterisk to Headline - MoNage
WebRTC From Asterisk to Headline - MoNageWebRTC From Asterisk to Headline - MoNage
WebRTC From Asterisk to Headline - MoNage
 
6 Months with WebRTC
6 Months with WebRTC6 Months with WebRTC
6 Months with WebRTC
 
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
 
AstriCon 2015: WebRTC: How it Works, and How it Breaks
AstriCon 2015: WebRTC: How it Works, and How it BreaksAstriCon 2015: WebRTC: How it Works, and How it Breaks
AstriCon 2015: WebRTC: How it Works, and How it Breaks
 
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...
AstriCon 2016 - Using Asterisk and XMPP to provide greater tools to your cust...
 
Kamailio - SIP Servers Everywhere
Kamailio - SIP Servers EverywhereKamailio - SIP Servers Everywhere
Kamailio - SIP Servers Everywhere
 
Exploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTCExploring the Possibilities of Sencha and WebRTC
Exploring the Possibilities of Sencha and WebRTC
 
How to set your ADI business profile
How to set your ADI business profileHow to set your ADI business profile
How to set your ADI business profile
 
Get to know Holiday Extras 2011
Get to know Holiday Extras 2011Get to know Holiday Extras 2011
Get to know Holiday Extras 2011
 
Holiday Extras
Holiday ExtrasHoliday Extras
Holiday Extras
 
Break away old
Break away oldBreak away old
Break away old
 
Apache Cordova, Hybrid Application Development
Apache Cordova, Hybrid Application DevelopmentApache Cordova, Hybrid Application Development
Apache Cordova, Hybrid Application Development
 
Exploring Open Date with BigQuery: Jenny Tong
Exploring Open Date with BigQuery: Jenny TongExploring Open Date with BigQuery: Jenny Tong
Exploring Open Date with BigQuery: Jenny Tong
 
Scottish Communicators Network - 22 October 2014 - People Make Glasgow
Scottish Communicators Network - 22 October 2014 - People Make GlasgowScottish Communicators Network - 22 October 2014 - People Make Glasgow
Scottish Communicators Network - 22 October 2014 - People Make Glasgow
 
Polyglot polywhat polywhy
Polyglot polywhat polywhyPolyglot polywhat polywhy
Polyglot polywhat polywhy
 
How to get started with Roadio in under 60 seconds
How to get started with Roadio in under 60 secondsHow to get started with Roadio in under 60 seconds
How to get started with Roadio in under 60 seconds
 

Similar to Asterisk, HTML5 and NodeJS; a world of endless possibilities

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
node.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Servernode.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the ServerDavid Ruiz
 
Introducing to node.js
Introducing to node.jsIntroducing to node.js
Introducing to node.jsJeongHun Byeon
 
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...Amazon Web Services
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Cloud Security @ Netflix
Cloud Security @ NetflixCloud Security @ Netflix
Cloud Security @ NetflixJason Chan
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
Leveraging the azure cloud for your mobile apps
Leveraging the azure cloud for your mobile appsLeveraging the azure cloud for your mobile apps
Leveraging the azure cloud for your mobile appsMarcel de Vries
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...Matt Spradley
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchMongoDB
 

Similar to Asterisk, HTML5 and NodeJS; a world of endless possibilities (20)

What Is Happening At The Edge
What Is Happening At The EdgeWhat Is Happening At The Edge
What Is Happening At The Edge
 
Node azure
Node azureNode azure
Node azure
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
node.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Servernode.js - Eventful JavaScript on the Server
node.js - Eventful JavaScript on the Server
 
Introducing to node.js
Introducing to node.jsIntroducing to node.js
Introducing to node.js
 
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...
CTD307_Case Study How Mobile Device Service Company Asurion Architected Its A...
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Cloud Security @ Netflix
Cloud Security @ NetflixCloud Security @ Netflix
Cloud Security @ Netflix
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
Leveraging the azure cloud for your mobile apps
Leveraging the azure cloud for your mobile appsLeveraging the azure cloud for your mobile apps
Leveraging the azure cloud for your mobile apps
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
 
Node.JS briefly introduced
Node.JS briefly introducedNode.JS briefly introduced
Node.JS briefly introduced
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
IoT-javascript-2019-fosdem
IoT-javascript-2019-fosdemIoT-javascript-2019-fosdem
IoT-javascript-2019-fosdem
 
NodeJS
NodeJSNodeJS
NodeJS
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 

More from Dan Jenkins

Yup... WebRTC Still Sucks
Yup... WebRTC Still SucksYup... WebRTC Still Sucks
Yup... WebRTC Still SucksDan Jenkins
 
Professional AV with WebRTC
Professional AV with WebRTCProfessional AV with WebRTC
Professional AV with WebRTCDan Jenkins
 
Getting started with WebRTC
Getting started with WebRTCGetting started with WebRTC
Getting started with WebRTCDan Jenkins
 
JanusCon - Building Native Mobile Apps with WebRTC
JanusCon - Building Native Mobile Apps with WebRTCJanusCon - Building Native Mobile Apps with WebRTC
JanusCon - Building Native Mobile Apps with WebRTCDan Jenkins
 
Getting Physical with Web Bluetooth in the Browser Full Stack Toronto
Getting Physical with Web Bluetooth in the Browser Full Stack TorontoGetting Physical with Web Bluetooth in the Browser Full Stack Toronto
Getting Physical with Web Bluetooth in the Browser Full Stack TorontoDan Jenkins
 
Astricon 2016 - Scaling ARI and Production
Astricon 2016 - Scaling ARI and ProductionAstricon 2016 - Scaling ARI and Production
Astricon 2016 - Scaling ARI and ProductionDan Jenkins
 
Getting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserGetting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserDan Jenkins
 
Getting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserGetting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserDan Jenkins
 
WebRTC Reborn SignalConf 2016
WebRTC Reborn SignalConf 2016WebRTC Reborn SignalConf 2016
WebRTC Reborn SignalConf 2016Dan Jenkins
 
Web technology is getting physical, join the journey
Web technology is getting physical, join the journeyWeb technology is getting physical, join the journey
Web technology is getting physical, join the journeyDan Jenkins
 
WebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC applicationWebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC applicationDan Jenkins
 
Building the Best Experience for Your Customers and Your Business
Building the Best Experience for Your Customers and Your BusinessBuilding the Best Experience for Your Customers and Your Business
Building the Best Experience for Your Customers and Your BusinessDan Jenkins
 
WebRTC Reborn - Full Stack Toronto
WebRTC Reborn -  Full Stack TorontoWebRTC Reborn -  Full Stack Toronto
WebRTC Reborn - Full Stack TorontoDan Jenkins
 
WebRTC Reborn - Cloud Expo / WebRTC Summit
WebRTC Reborn - Cloud Expo / WebRTC SummitWebRTC Reborn - Cloud Expo / WebRTC Summit
WebRTC Reborn - Cloud Expo / WebRTC SummitDan Jenkins
 
WebRTC Reborn - Full Stack
WebRTC Reborn  - Full StackWebRTC Reborn  - Full Stack
WebRTC Reborn - Full StackDan Jenkins
 
Developing Yourself for Industry - University of Kent EDA MTD DA
Developing Yourself for Industry - University of Kent EDA MTD DADeveloping Yourself for Industry - University of Kent EDA MTD DA
Developing Yourself for Industry - University of Kent EDA MTD DADan Jenkins
 
Building 21st Century Contact Centre Applications
Building 21st Century Contact Centre ApplicationsBuilding 21st Century Contact Centre Applications
Building 21st Century Contact Centre ApplicationsDan Jenkins
 
WebRTC Reborn Hackference
WebRTC Reborn HackferenceWebRTC Reborn Hackference
WebRTC Reborn HackferenceDan Jenkins
 
WebRTC Reborn Over The Air
WebRTC Reborn Over The AirWebRTC Reborn Over The Air
WebRTC Reborn Over The AirDan Jenkins
 

More from Dan Jenkins (20)

Yup... WebRTC Still Sucks
Yup... WebRTC Still SucksYup... WebRTC Still Sucks
Yup... WebRTC Still Sucks
 
Professional AV with WebRTC
Professional AV with WebRTCProfessional AV with WebRTC
Professional AV with WebRTC
 
SIMCON 3
SIMCON 3SIMCON 3
SIMCON 3
 
Getting started with WebRTC
Getting started with WebRTCGetting started with WebRTC
Getting started with WebRTC
 
JanusCon - Building Native Mobile Apps with WebRTC
JanusCon - Building Native Mobile Apps with WebRTCJanusCon - Building Native Mobile Apps with WebRTC
JanusCon - Building Native Mobile Apps with WebRTC
 
Getting Physical with Web Bluetooth in the Browser Full Stack Toronto
Getting Physical with Web Bluetooth in the Browser Full Stack TorontoGetting Physical with Web Bluetooth in the Browser Full Stack Toronto
Getting Physical with Web Bluetooth in the Browser Full Stack Toronto
 
Astricon 2016 - Scaling ARI and Production
Astricon 2016 - Scaling ARI and ProductionAstricon 2016 - Scaling ARI and Production
Astricon 2016 - Scaling ARI and Production
 
Getting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserGetting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browser
 
Getting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browserGetting physical with web bluetooth in the browser
Getting physical with web bluetooth in the browser
 
WebRTC Reborn SignalConf 2016
WebRTC Reborn SignalConf 2016WebRTC Reborn SignalConf 2016
WebRTC Reborn SignalConf 2016
 
Web technology is getting physical, join the journey
Web technology is getting physical, join the journeyWeb technology is getting physical, join the journey
Web technology is getting physical, join the journey
 
WebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC applicationWebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC application
 
Building the Best Experience for Your Customers and Your Business
Building the Best Experience for Your Customers and Your BusinessBuilding the Best Experience for Your Customers and Your Business
Building the Best Experience for Your Customers and Your Business
 
WebRTC Reborn - Full Stack Toronto
WebRTC Reborn -  Full Stack TorontoWebRTC Reborn -  Full Stack Toronto
WebRTC Reborn - Full Stack Toronto
 
WebRTC Reborn - Cloud Expo / WebRTC Summit
WebRTC Reborn - Cloud Expo / WebRTC SummitWebRTC Reborn - Cloud Expo / WebRTC Summit
WebRTC Reborn - Cloud Expo / WebRTC Summit
 
WebRTC Reborn - Full Stack
WebRTC Reborn  - Full StackWebRTC Reborn  - Full Stack
WebRTC Reborn - Full Stack
 
Developing Yourself for Industry - University of Kent EDA MTD DA
Developing Yourself for Industry - University of Kent EDA MTD DADeveloping Yourself for Industry - University of Kent EDA MTD DA
Developing Yourself for Industry - University of Kent EDA MTD DA
 
Building 21st Century Contact Centre Applications
Building 21st Century Contact Centre ApplicationsBuilding 21st Century Contact Centre Applications
Building 21st Century Contact Centre Applications
 
WebRTC Reborn Hackference
WebRTC Reborn HackferenceWebRTC Reborn Hackference
WebRTC Reborn Hackference
 
WebRTC Reborn Over The Air
WebRTC Reborn Over The AirWebRTC Reborn Over The Air
WebRTC Reborn Over The Air
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Asterisk, HTML5 and NodeJS; a world of endless possibilities

  • 1. Asterisk, HTML5 and NodeJS; a world of endless possibilities Dan Jenkins Astricon 2012 @dan_jenkins @holidayextras
  • 2. The next half an hour.... • Introductions • Who Holiday Extras are • HTML5 • What’s NodeJS • How we’ve used NodeJS within our production environment • Demonstration
  • 3. Who am I? el op er Dan Jenkins D ev eb neer r W ngi @dan_jenkins 2 Years S io en oIP E & V Author of Asterisk-AMI Module
  • 4. It’s in the name, we sell extras for holidays We’re partners with some big names in the UK travel industry Theme Park Breaks easyJet Legoland, Alton Towers to name just a few British Airways Thomas Cook Theatre Breaks
  • 5. Since moving to Asterisk, Over 800,000 calls through we’ve taken ~516,000 phone calls in our Contact Centre our Contact Centre last year We are the market leaders! We believe Holidays should be Hassle Free We’ve been using Asterisk in production since April Operate in mainland Europe too, with Holiday Extras DE We’re a 29 year old start up
  • 7. What’s so great about HTML5? Easier to iterate, there’s millions of web developers out there No extra plugins required! Faster time to launch Over 60% of users with Internet access have browsers that Make fully featured apps suppport HTML5 direct in the browser
  • 8. What can you do with HTML5? Client-side databases Get User Media (Microphone & Video) Offline Application cache Web workers (Threads) WebRTC Two way, real-time, (SIP phone in the browser) communication
  • 9. So, what’s NodeJS? “Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
  • 10. What have Holiday Extras done? Integrated control of the call directly into our in-house CRM system, this also allows us to look up our customer in realtime We’ve been through about 3 iterations of the integration NodeJS and HTML5 have given us the ability to do this We are able to move fast to react to the current needs of our business
  • 11. How does it all fit together? NodeJS Asterisk Server Web Sockets Asterisk-AMI TCP Socket SIP Chrome Firefox Safari + SF + SF + SF
  • 12. Now for the demo @dan_jenkins @holidayextras
  • 13. Firstly, install the module npm install asterisk-ami Prerequisite: install NodeJS first!
  • 14. Create a basic NodeJS server Output a ping response from Asterisk in the command line, from the NodeJS app
  • 15. server.js var AsteriskAmi = require('asterisk-ami'); var ami = new AsteriskAmi( { host: '172.16.172.130', username: 'astricon', password: 'secret' } ); ami.on('ami_data', function(data){   console.log('AMI DATA', data); }); ami.connect(function(response){   console.log('connected to the AMI');   setInterval(function(){     ami.send({action: 'Ping'});//run a callback event when we have connected to the socket   }, 2000); }); process.on('SIGINT', function () {   ami.disconnect(); " process.exit(0); }); github.com/danjenkins/astricon-2012
  • 16. Time to step it up a notch, let’s make it output to a webpage Output that same ping response to a browser, using NodeJS
  • 17. server.js var AsteriskAmi = require('asterisk-ami'); var nowjs = require("now"); var fs = require('fs'); var express = require('express'); var http = require('http'); var ami = new AsteriskAmi( { host: '172.16.172.130', username: 'astricon', password: 'secret' } ); var app = express(); var server = http.createServer(app).listen(8080, function(){   console.log('listening on http://localhost:8080'); }); app.configure(function(){   app.use("/assets", express.static(__dirname + '/assets')); }); github.com/danjenkins/astricon-2012
  • 18. app.use(express.errorHandler()); app.get('/', function(req, res) {   var stream = fs.createReadStream(__dirname + '/webpage.html');   stream.on('error', function (err) {       res.statusCode = 500;       res.end(String(err));   });   stream.pipe(res); }) var everyone = nowjs.initialize(server); ami.on('ami_data', function(data){   if(everyone.now.echoAsteriskData instanceof Function){     everyone.now.echoAsteriskData(data);   } }); github.com/danjenkins/astricon-2012
  • 19. ami.connect(function(response){   console.log('connected to the AMI');   setInterval(function(){     ami.send({action: 'Ping'});//run a callback event when we have connected to the socket   }, 2000); }); process.on('SIGINT', function () {   ami.disconnect();   process.exit(0); }); github.com/danjenkins/astricon-2012
  • 20. webpage.html <script type="text/javascript" src="/nowjs/now.js"></script> <script type="text/javascript"> var output = function(data){   var html = '<div>' + (data instanceof Object ? JSON.stringify(data) : data) + '</div>';   var div = document.getElementById('output');    div.innerHTML = html + div.innerHTML;   }   now.echoAsteriskData = function(data){    output(data);   }   now.ready(function(){     output('connected via nowjs');   }); </script> github.com/danjenkins/astricon-2012
  • 21. Now, let’s create a call from the webpage via Bria - Asterisk 11 - SIP Phone Let’s make the browser do something, make it create a call between two sip extensions
  • 22. server.js +everyone.now.send_data_to_asterisk = function(data){ +  console.log('got data from browser', data); +  ami.send(data); +} github.com/danjenkins/astricon-2012
  • 23. webpage.html $('.btn').click(function(e){ var obj = {};   if($(this).is('.help')){    obj = {action: 'ListCommands'};   }else if($(this).is('.reload')){     obj = {action: 'reload'};   }else if($(this).is('.login')){     obj = {action: 'QueueAdd', queue: '10', interface: 'sip/2000', penalty: 1, paused: true};   }else if($(this).is('.unpause')){     obj = {action: 'QueuePause', queue: '10', interface: 'sip/2000', paused: false};   }else if($(this).is('.dial')){     obj = { action: 'originate', channel: 'SIP/1000', exten: 10, context: 'from-internal', priority : 1, async: true, callerid: '1000 VIA AMI "1000"' };   }else if($(this).is('.logout')){    obj = {action: 'QueueRemove', queue: '10', interface: 'sip/2000'};   }   now.send_data_to_asterisk(obj); e.preventDefault(); }) github.com/danjenkins/astricon-2012
  • 25. Thank You! Dan Jenkins @dan_jenkins Astricon 2012 dan.jenkins@holidayextras.com hungrygeek.holidayextras.co.uk npm.im/asterisk-ami github.com/holidayextras/node-asterisk-ami