Skip to content

Instantly share code, notes, and snippets.

@adambutler
Last active November 15, 2017 10:16
Show Gist options
  • Save adambutler/87fec2589ccef62c3bb89cfd4d02e724 to your computer and use it in GitHub Desktop.
Save adambutler/87fec2589ccef62c3bb89cfd4d02e724 to your computer and use it in GitHub Desktop.

Join a conference call

Specification

A building block that shows how to handle an inbound call that joins a conference call

  • You must specify one endpoint must be on the path /webhooks/answer

  • Your endpoint must be accessible on a GET request

  • Your endpoint must listen on port 3000

  • Your response should return a 200 status code

  • Your response should be JSON NCCO with the the following or equivalent body:

    • GET request:
    $ curl "http://127.0.0.1:3000/webhooks/answer"
    

    Should result in the response:

    [
      {
        "action": "talk",
        "text": "Welcome to a Nexmo powered conference call"
      },
      {
        "action": "conversation",
        "name": "room-name"
      }
    ]
  • Code examples should include a GitHub link to the file

  • Code examples should include the line numbers used from the linked file

  • All code examples must be present in the master branch of the relevant quickstart repo

  • All code examples must be tested to work (manual testing is fine)

Instructions

  1. Fork this gist
  2. Edit the gist and the building block files to match the specification
  3. Return Gist as a comment in the original issue

Join a conference call

Joining conference calls with Nexmo is easy. In this example we'll accept an inbound call and add the caller into a conference call.

Replace the following variables in the example below:

Implement a webhook

// GITHUB: https://github.com/nexmo-community/nexmo-node-quickstart/blob/master/voice/conference-call.js
// Lines: ALL LINES

const app = require('express')()
const bodyParser = require('body-parser')

app.use(bodyParser.json())

const onInboundCall = (request, response) => {
  const ncco = [
    {
      action: 'talk',
      text: 'Welcome to a Nexmo powered conference call'
    },
    {
      action: 'conversation',
      name: 'room-name'
    }
  ]

  response.json(ncco)
}

app.get('/webhooks/answer', onInboundCall)

app.listen(3000)

Run your server

Save this file to your machine and run it using the node command:

$ node app.js

You'll need to expose your server to the open internet. During development you can use a tool like Ngrok to do that.

Associate an application to your webhook

To link your number to the endpoint you've just created we'll need an Application.

$ nexmo app:create demo <YOUR_HOSTNAME>/webhooks/answer <YOUR_HOSTNAME>/webhooks/event
$ nexmo link:app <NEXMO_NUMBER> <NEXMO_APPLICATION_ID>

Call your number

When you call your Nexmo number you should added to the conference. You can call from another line and have up to 50 participants on the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment