Skip to content

Instantly share code, notes, and snippets.

@mheap

mheap/_README.md Secret

Forked from adambutler/_README.md
Last active November 29, 2017 12:57
Show Gist options
  • Save mheap/92c9f9740e7a53c4374497e4230187de to your computer and use it in GitHub Desktop.
Save mheap/92c9f9740e7a53c4374497e4230187de 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-php-quickstart/blob/master/voice/conference-call-slim/index.php
// Lines: ALL LINES

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \Slim\App;

$app->get('/webhooks/answer', function (Request $request, Response $response) {
    $ncco = [
        [
            'action' => 'talk',
            'text' => 'Welcome to a Nexmo powered conference call'
        ],
        [
            'action' => 'conversation',
            'name' => 'room-name'
        ]
    ];

    return $response->withJson($ncco);
});


$app->run();

Run your server

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

$ php -t . -S 127.0.0.1:3000

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