Before you begin

What are Code Snippets?

Code snippets are short pieces of code you can reuse in your own applications. The code snippets utilise code from the Nexmo Node Code Snippets and Nexmo Curl Code Snippets repositories.

Please read this information carefully, so you can best use the code snippets.

Prerequisites

  1. Create a Nexmo Account
  2. Install Node JS - required for using the Nexmo Command Line Interface (CLI).
  3. Install the Beta version of the Nexmo CLI
  4. Install or update the Beta version of the Nexmo Node client library - only required if using Node.
  5. Configure webhooks.
  6. Know how to write a webhook server
  7. Know how to test your webhook server locally

Replaceable variables

Generic replaceable

The following replaceable information depends on the library and specific call:

Key Description
NEXMO_API_KEY API key.
NEXMO_API_SECRET API secret.
NEXMO_APPLICATION_PRIVATE_KEY_PATH Private key path.
NEXMO_APPLICATION_PRIVATE_KEY Private key.
NEXMO_APPLICATION_ID The Nexmo Application ID.

Numbers

All phone numbers are in E.164 format.

Key Description
NEXMO_NUMBER Replace with your Nexmo Number. E.g. 447700900000
FROM_NUMBER Replace with number you are sending from. E.g. 447700900002
TO_NUMBER Replace with the number you are sending to. E.g. 447700900001

Specific replaceable/variables

Some code snippets have more specialised variables, such as Facebook Page IDs, that will need to be replaced by actual values. Where required, these are specified on a per-code snippet basis.

Webhooks

The main ones you will meet here are:

If you are testing locally using Ngrok you will set your webhook URLs in the Nexmo Application object using a format similar to the following examples:

Change demo in the above with whatever Ngrok generates for you, unless you have paid for a reusable URL.