JavaScript

Configure your prerequisites

There are a few prerequisites that you need to complete before you can work through this tutorial. If you've already completed any of them, feel free to skip that step.


To use Smart Numbers, you need to enable the Smart Number add-on in your account:

  1. Visit the VBC Admin Portal and log in.
  2. From the navigation menu, select Store > Add-Ons.
  3. Search for "smart" to filter the list of add-ons:
    Enable the Smart Numbers add-on
    Enable the Smart Numbers add-on
  4. Click Add to add Smart Number to your shopping basket.
  5. Note the recurring monthly fee and click Checkout.
  6. On the Order Preview page, verify your Account payment method and click Submit Order.

You have now enabled Smart Numbers. The next step is to create a Nexmo Voice Application.

Every Smart Numbers application you build must be associated with a Nexmo Voice Application.

Note: To avoid confusion, Application here refers to the Nexmo Application. The application you are building will be referred to as "application".

A Nexmo Application stores configuration information such as details of the Smart Numbers and webhook callback URLs that your application uses. To make your VBC Smart Number calls zero-rated in Nexmo, you must create an Application with the vbc and voice capabilities, using the Nexmo Application API.

Using the Application API

To create a Nexmo Application for working with Smart Numbers, issue the curl command shown below, replacing NEXMO_API_KEY and NEXMO_API_SECRET with your Nexmo API key and secret respectively. You can find this information in the Nexmo Developer dashboard.

The two URLs you provide refer to the webhook endpoints that your application will expose to Nexmo's servers:

  • The first is the webhook to which Nexmo's APIs will make a request when a call is received on your Smart Number.
  • The second is where Nexmo's APIs will post details about events that your application might be interested in - such as a call being answered or terminated.
curl -X POST \
  https://api.nexmo.com/v2/applications \
  -H 'Authorization: Basic Base64($NEXMO_API_KEY:$NEXMO_API_SECRET)' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "My Nexmo VBC Application",
    "capabilities": {
      "vbc": {},
      "voice": {
        "webhooks": {
          "answer_url": {
            "address": "https://example.com/webhooks/answer",
            "http_method": "POST"
          },
          "event_url": {
            "address": "https://example.com/webhooks/event",
            "http_method": "POST"
          }
        }
      }
      }
  }'

The response is a JSON object containing the Nexmo Application id that you will use to interact with the Nexmo Voice API.

{
  "id": "27aa0583-7246-4822-aabb-17b03c25d52e",
  "name": "My Nexmo VBC Application",
  "keys": {
    "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkq...
    -----END PRIVATE KEY-----\n",
    "public_key": "-----BEGIN PUBLIC_KEY-----\nMIIBIjANBgkqh...
    -----END PUBLIC KEY-----\n"
  },
  "capabilities": {
    "voice": {
      "webhooks": {
        "event_url": {
            "address": "https://example.com/webhooks/event",
            "http_method": "POST"
        },
        "answer_url": {
            "address": "https://example.com/webhooks/answer",
            "http_method": "POST"
        }
      }
    },
    "vbc": {}
  },
  "_links": {
    "self": {
      "href": "/v2/applications/27aa0583-7246-4822-aabb-17b03c25d52e"
    }
  }
}

The next step is to provision Smart Numbers using the Nexmo Application id.

Once you have enabled the Smart Numbers add-on in your VBC account and created a Nexmo Voice API Application, you are ready to provision the Smart Numbers service. This involves selecting which numbers to use and associating them with your Nexmo Voice API Application.

  1. Sign into the VBC Admin Portal

  2. In the left-hand navigation menu, select the Business Apps > Smart Numbers menu option.

    Note: If you do not see the Smart Numbers menu option, you must enable the add-on.

  3. Each row in the table refers to a Smart Number. Click one of your unconfigured Smart Numbers to edit it.

  4. On the Edit Smart Numbers Service page:

    1. Enter a name for the service.
    2. Select at least one direct dial number that you will call to access the Nexmo Voice API application.
    3. Paste in your Nexmo Voice API application_id.
    4. Ensure that the Smart Number Status switch is set to Active.
    5. Click the Save button.

Edit your Smart Number
Edit your Smart Number

You have now provisioned the Smart Numbers service and are ready to begin developing your application. See this list of resources to get started.


Smart Numbers IVR

Redirect calls from your Smart Number to another number



Steps