nexmo-sms-teneo

by pomegran

GitHub Readme.md

nexmo-sms-teneo

This node.js example connector allows you to make your Teneo bot available via Nexmo SMS. The connector acts as middleware between Nexmo and Teneo and an SMS text communication with a Teneo bot, persisting state, conversational position etc. For more information on the Nexmo SMS API, go to https://developer.nexmo.com/api/sms.

Prerequisites

HTTPS

Nexmo API requires that the connector is available via https. Ngrok is recommended for this.

  1. Make sure your connector is available via https. When running locally you can for example use ngrok for this. Run the connector on port 1337 by default.
    ngrok http 1337
    
  2. Running the command above will display a public https URL, copy it, we will use it as a Webhook URL for the following steps.

Running the connector locally

Nexmo Setup

  1. Under your phone number, go to "Manage" and set the "Inbound Webhook URL" to your ngrok HTTPS endpoint above, adding the path /teneochat to the end.

  2. Also ensure your default SMS settings are set to HTTP Method of "POST" - https://dashboard.nexmo.com/settings

Connector Setup Instructions

  1. Download or clone the connector source code:
    git clone https://github.com/pomegran/nexmo-sms-teneo.git
    
  2. Install dependencies by running the following command in the folder where you stored the source:
    npm install
    
  3. Start the connector with the following command (replacing the environment variables with the appropriate values):
    NEXMO_NUMBER=<Number_to_send_the_SMS_from_in_E.164_format> NEXMO_API_KEY=<Nexmo_API_key> NEXMO_API_SECRET=<Nexmo API Secret> TENEO_ENGINE_URL=<your_engine_url> node server.js
    

Text the Nexmo number with your phone, and speak to your bot!

Running the connector on Heroku

Click the button below to deploy the connector to Heroku:

Deploy

In the 'Config Vars' section, add the following:

  • TENEO_ENGINE_URL: The engine url
  • NEXMO_NUMBER: Number to send the SMS from in E.164 format
  • NEXMO_API_KEY: Nexmo API key
  • NEXMO_API_SECRET: Nexmo API secret
  • PORT: Port to run the application on (defaults to 1337 if not specified)

Sending SMS

There may be the requirement to send a standalone SMS e.g. confirmation of a completed dialogue to the user etc. There is a standalone call that allows this to be done:

  1. POST to the endpoint above adding the path /sendsms to the end, including the following JSON in the body
{
	"phoneNumber":"<Number to send the SMS to in E.164 format>",
	"message":"<Your message>"
}