SMS is a text messaging service component of most communication systems. Analysis of text message content can highlight customer inquiry patterns and response effectiveness.

Welcome to the SMS documentation for Dashbot! Integrating Dashbot into your SMS chatbot is quick and easy.

If you have any questions, comments, or suggestions, please feel free to contact us.

SMS Integration with NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).sms;

Whenever your bot sends, or receives data, log to Dashbot

Message Format

You can send the following fields:

  • text – string – (required)
  • userId – string – (required) – should be the SAME userId for both incoming
    and outgoing messages this is NOT the bot’s user ID
  • intent – object – (optional)
    • name – string
    • inputs – array
      • input – object
        • name – string
        • value – string
  • images – array – (optional)
    • image – object
      • url – string
  • buttons – array – (optional)
    • button – object
      • id – string
      • label – string
      • value – string
  • postback – object (optional)
    • buttonClick – object
      • buttonId – string
  • platformJson – object (optional) – send ALL of your platform-specific
    JSON here. It will be available for viewing in your transcripts.

Log whenever your webhook is called

const messageForDashbot = {
  "text": "Hi, bot",
  "userId": "+14155551234",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here -- if you are using Twilio, put the req.body here"
  }
};
dashbot.logIncoming(messageForDashbot);

Whenever you send a message, log the response

const messageForDashbot = {
  "text": "Hello, my human pet",
  "userId": "+14155551234",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here -- if you are using Twilio, put the req.body here"
  }
};
dashbot.logOutgoing(messageForDashbot);

Example

View sample code for complete example.


SMS Integration with REST API

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Integrate the REST API

There are two integration points as outlined below.

1. When bot posts to your webhook endpoint

When your bot receives a message, post the data to the following endpoint:

https://tracker.dashbot.io/track?platform=sms&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
  "text": "Hi, bot",
  "userId": "+14155551234",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here"
  }
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
     -d '{"text":"Hi, bot","userId":"+14155551234","platformJson":{"whateverJson":"any JSON specific to your platform can be stored here"}}'
     'https://tracker.dashbot.io/track?platform=sms&v=11.1.0-rest&type=incoming&apiKey=API_KEY'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.

Note
This is just an example — we accept all the fields at the top of the page.

2. When your bot sends a message

When your bot sends a message, POST to the following endpoint:

https://tracker.dashbot.io/track?platform=sms&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE

Make sure to set the ‘Content-Type’ header to ‘application/json’ and to replace API_KEY_HERE with your api key.

The data to POST should pass the following data:

{
  "text": "Hello, my human pet",
  "userId": "+14155551234",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here"
  }
}

Sample cURL

curl -X POST -H "Content-Type: application/json"
     -d '{"text":"Hello, my human pet","userId":"+14155551234","platformJson":{"whateverJson":"any JSON specific to your platform can be stored here"}}'
     'https://tracker.dashbot.io/track?platform=sms&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE'

Notice, you must replace the placeholder API_KEY_HERE above with your api key.