Connect callers to a conference
This code snippet shows how to join multiple calls into a conversation.
Multiple inbound calls can be joined into a conversation (conference call) by connecting the call into the same named conference.
Conference names are scoped at the Vonage Application level. For example, VonageApp1 and VonageApp2 could both have a conference called vonage-conference and there would be no problem.
Prerequisites
Create an Application
You can install the CLI with the following command:
Before you can start working with your apps, you need to register your configuration: API Key and Secret. You can find them via the Dashboard, in API Settings. Once set, initialize your account using the following command:
As soon as the CLI is both installed and configured, use it to create a Vonage application using the following command:
The command starts an interactive prompt to ask for the application name, and the capabilities you want to enable - make sure to enable Voice.
When finished, it creates the vonage_app.json file in the current directory containing the Application ID, Application name and private key. It also creates a second file with the private key name app_name.key.
Go to the Application's page on the Dashboard, and define a Name for your Application.

Make sure to click on the Generate public and private key button, and keep the file private.key around.
Then, enable the Voice capability. For the moment, leave everything by default.

Finally, click Save at the bottom of the page.
Rent a Number
You can rent a number using the Vonage CLI. The following command purchases an available number in the United States:
Specify an alternative two-character country code to purchase a number in another country.
In the Dashboard, go to the Buy Numbers page. Make sure to tick Voice in the search filter, and select the country you want to buy a number in.

You can then click the Buy button next to the number you want, and validate your purchase.
Congratulations! Your virtual number is now listed in Your Numbers
Link a Number
Now that you have both an application and a number, you need to link them together.
Replace YOUR_VONAGE_NUMBER with the number you bought and APPLICATION_ID with your application id, then run the following command:
Now that you have both an application and a number, you need to link them together.
Go to the Application page, and click on the application you created earlier.

In the Voice section, click on the Link button next to the number you want to link.
Example
Replace the following variables in the example code:
| Key | Description |
|---|---|
CONF_NAME | The named identifier for your conference. |
Prerequisites
npm install express body-parserWrite the code
Add the following to conference-call.js:
const Express = require('express');
const app = new Express();
const bodyParser = require('body-parser');
app.use(bodyParser.json());
const onInboundCall = (request, response) => {
const ncco = [
{
action: 'talk',
text: 'Please wait while we connect you to the conference',
},
{
action: 'conversation',
name: CONF_NAME,
},
];
response.json(ncco);
};
app.get('/webhooks/answer', onInboundCall);
app.listen(3000);Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:1.1.2'
implementation 'io.ktor:ktor-server-netty'
implementation 'io.ktor:ktor-serialization-jackson'Write the code
Add the following to the main method of the ConnectCallersToConference file:
embeddedServer(Netty, port = 8000) {
routing {
route("/webhooks/answer") {
handle {
call.response.header("Content-Type", "application/json")
call.respond(
Ncco(
talkAction("Please wait while we connect you to the conference."),
conversationAction(CONF_NAME)
).toJson()
)
}
}
}
}.start(wait = true)Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.voice with the package containing ConnectCallersToConference:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:8.15.1'
implementation 'com.sparkjava:spark-core:2.9.4'Write the code
Add the following to the main method of the ConferenceCall file:
/*
* Route to answer incoming calls with an NCCO response.
*/
Route answerRoute = (req, res) -> {
TalkAction intro = TalkAction.builder("Please wait while we connect you to the conference.").build();
ConversationAction conversation = ConversationAction.builder(CONF_NAME).build();
res.type("application/json");
return new Ncco(intro, conversation).toJson();
};
Spark.port(3000);
Spark.get("/webhooks/answer", answerRoute);
Spark.post("/webhooks/answer", answerRoute);Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.voice with the package containing ConferenceCall:
Prerequisites
Install-Package VonageWrite the code
Add the following to ConnectCallersToConferenceController.cs:
[HttpGet("webhooks/answer")]
public string Answer()
{
var confName = Environment.GetEnvironmentVariable("CONF_NAME") ?? "CONF_NAME";
var talkAction = new TalkAction() { Text = "Please wait while we connect you to the conference" };
var conversationAction = new ConversationAction() { Name = confName };
var ncco = new Ncco(talkAction, conversationAction);
return ncco.ToString();
}Prerequisites
composer require vonage/client slim/slim:^3.8Write the code
Add the following to index.php:
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->get('/webhooks/answer', function (Request $request, Response $response) {
$talk = new \Vonage\Voice\NCCO\Action\Talk('Hi, welcome to this Nexmo conference call');
$convo = new \Vonage\Voice\NCCO\Action\Conversation('nexmo-conference-standard');
$ncco = new \Vonage\Voice\NCCO\NCCO();
$ncco->addAction($talk);
$ncco->addAction($convo);
return new JsonResponse($ncco->toArray());
});
$app->run();Run your code
Save this file to your machine and run it:
Prerequisites
pip install 'flask>=1.0'Write the code
Add the following to connect-callers-to-a-conference.py:
from flask import Flask, jsonify
from os.path import join, dirname
from dotenv import load_dotenv
import os
app = Flask(__name__)
dotenv_path = join(dirname(__file__), "../.env")
load_dotenv(dotenv_path)
CONFERENCE_NAME = os.environ.get("CONFERENCE_NAME")
@app.route("/webhooks/answer")
def answer_call():
ncco = [
{
"action": "talk",
"text": "Please wait while we connect you to the conference"
},
{
"action": "conversation",Run your code
Save this file to your machine and run it:
Prerequisites
gem install sinatra sinatra-contribWrite the code
Add the following to join_a_conference_call.rb:
require 'sinatra'
require 'sinatra/multi_route'
require 'json'
before do
content_type :json
end
route :get, :post, '/webhooks/answer' do
[
{
action: 'talk',
text: 'Welcome to a Vonage powered conference call'
},
{
action: 'conversation',
name: 'room-name'
}
].to_json
end
set :port, 3000Run your code
Save this file to your machine and run it:
Try it out
Start your server and make multiple inbound calls to the Vonage Number assigned to this Vonage Application. The inbound calls will be connected into the same conversation (conference).
Further Reading
- Conference Calling - This guide explains the two concepts Vonage associates with a call, a leg and a conversation.