Build a Conference Call with ASP.NET

Build a Conference Call with the Nexmo Voice API and ASP.NET Core

Published May 16, 2019 by Rabeb Othmani

This is the sixth tutorial on how to use Voice APIs with ASP.NET series.
In the previous tutorial, we learnt how to forward a call via voice proxy with ASP.NET Core.

In today’s tutorial, we will learn how to setup a conference call so multiple people can join the same call.

Learning objectives

In this tutorial, we will:

  • Create an ASP.NET Core app.

  • Use NancyFX with ASP.NET Core.

  • Create a Nexmo voice application.

  • Create and return NCCOs.

  • Run and test the code using Ngrok.

Prerequisites

  • Visual Studio 2017 or higher.

  • A Nexmo account, which you can sign up for here.

  • A project setup for this tutorial series, which you can find on Github.

  • Optional: The Nexmo CLI.

Configuration

To use The Nexmo Voice API, we need to create a voice application.

The configuration steps are detailed in the Nexmo Voice API with ASP.NET: Before you start post.

Once the configuration is done successfully, we can move on to setting up a conference call.

Building a Conference Call

When a user calls the Nexmo number, the Nexmo Voice API will make a request to the application to figure out how to respond using a Nexmo Call Control Object (NCCO).

The user will be greeted then will join the conference call.

For that purpose, we are going to use NancyFX along side our ASP.NET Core project.

First of all, we need to add Nancy to our project :

To allow Nancy to handle any HTTP requests, we need to tell ASP.NET Core to use Nancy via Owin in the Configure method of Startup.cs.

The next step is to create a Nancy module in which we setup a route to /webhook/answer which will respond with the ncco returned by GetConferenceCallNCCO()

The above code will do the following:

When a call is received, the user will hear “Hello. You will now be added to the conference call.” then they will be added to the conference call.

Multiple callers can be added to the conference until they all have disconnected.

We are done! To test this sample app, some more configuration steps are required.

Linking Your App to Nexmo

If you’ve been following along so far, you’ve already configured your Nexmo account and created a voice app as shown in this post. We need to link this app to a the Nexmo phone number that we are going to call.

If you don’t have a number, you can purchase one using the dashboard or the by using the Nexmo CLI:

Similarly to link the number, you can use the dashboard or the CLI:

We need to tell Nexmo which URL to make a request to when a call is received – this is called the answer_url. For me, this url is http://localhost:63286/webhook/answer and that’s only running locally.

To expose our webhook answer url, we will use Ngrok.

We now have a new url (mine is http://.ngrok.io) that can be used as the answer_url for the voice application.

Update your application with your new answer_url. It should look like http://subdomain.ngrok.io/webhook/answer. Run the app and give it a go by calling the TO_NUMBER.

Learn more

API References and Tools

Nexmo Getting Started Guides for ASP.NET

Leave a Reply

Your email address will not be published.