If a 1-click integration for your vendor does not exist or you prefer finer-grained control over when messages are sent to Dashbot and the information contained within them, consider using the Dashbot Tracker. This is a REST API that allows you to send data to Dashbot. Integrating Dashbot into your chatbot, web bot, SMS bot, voice application, or other conversational interface, is quick and easy. We are going to walk through two main ways to integrate with Dashbot, one being with Node & the other with the REST API.
Node Integration
Create an API key
Here is a quick video guide on how to generate you Dashbot API keys.
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).universal;
Notice above, we assume you have set an environment variable DASHBOT_API_KEY
with your api key.
Whenever your bot sends, or receives data, log to Dashbot
See below for an example.
Log whenever your webhook is called
const messageForDashbot = {
"text": "Hi, bot",
"userId": "USERIDHERE123123",
"platformJson": {
"whateverJson": "any JSON specific to your platform can be stored here"
}
};
dashbot.logIncoming(messageForDashbot);
Whenever you send a message, log the response
const messageForDashbot = {
"text": "Hello, my human pet",
"userId": "USERIDHERE123123",
"platformJson": {
"whateverJson": "any JSON specific to your platform can be stored here"
}
};
dashbot.logOutgoing(messageForDashbot);
Example
View sample code.
REST Integration
Using the Universal integration, you can use Dashbot with any conversational user interface.
Create an API key
Here is a quick video guide on how to generate you Dashbot API keys
There are two integration points as outlined below. Before diving into the integration points, the message format section
describes the payload you will be logging to Dashbot.
Message Format
You can send the fields listed above with the following as an example:
{
text: "I'd like to place an order for a pizza using 1 bitcoin",
userId: "user01",
intent: {
name: "Order",
inputs: [{
name: "Dish",
value: "Pizza"
}, {
name: "Payment",
value: "1 bitcoin"
}],
confidence: 1.0
},
images: [
"https://i.example.com/orders/pizza.png"
],
buttons: [{
id: "=ay13.x",
label: "Pizza",
value: "pizza"
}, {
id: "=asdf2",
label: "Drink",
value: "drink"
}],
postback: {
buttonClick: {
buttonId: "=ay13.x"
}
},
platformJson: {},
platformUserJson: {},
sessionId: "1"
}
1. When your bot receives a message
When your bot receives a message, post the data to the following endpoint:
https://tracker.dashbot.io/track?platform=universal&v=10.1.1-rest&type=incoming&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’ and replace API_KEY_HERE
with your api key.
The data to POST should pass the following data:
{
"text": "Hi, bot",
"userId": "USERID_01",
"platformJson": {
"whateverJson": "any JSON specific to your platform can be stored here"
}
}
Sample cURL
curl -X POST -H "Content-Type: application/json" <br></br>
-d '{"text":"Hi, bot","userId":"USERIDHERE123123","platformJson":{"whateverJson":"any JSON specific to your platform can be stored here"}}' <br></br>
'https://tracker.dashbot.io/track?platform=universal&v=11.1.0-rest&type=incoming&apiKey=API_KEY_HERE'
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 listed 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=universal&v=11.1.0-rest&type=outgoing&apiKey=API_KEY_HERE
Make sure to set the ‘Content-Type’ header to ‘application/json’ and replace API_KEY_HERE
with your api key.
The data to POST should pass the following data:
{
"text": "Hello, my human pet",
"userId": "USERIDHERE123123",
"platformJson": {
"whateverJson": "any JSON specific to your platform can be stored here"
}
}
Sample cURL
curl -X POST -H "Content-Type: application/json" <br></br>
-d '{"text":"Hello, my human pet","userId":"USERIDHERE123123","platformJson":{"whateverJson":"any JSON specific to your platform can be stored here"}}' <br></br>
'https://tracker.dashbot.io/track?platform=universal&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.
Sample JSON with optional fields
{
"text": "Hello, my human pet",
"userId": "USERIDHERE123123",
"intent": {
"name": "HELLO"
},
"images": [{
"url": "https://media.giphy.com/media/mIZ9rPeMKefm0/giphy.gif"
}],
"platformUserJson": {
"firstName": "Will",
"lastName": "Robinson",
"locale": "en_US",
"timezone": "-8",
"gender": "male"
},
"platformJson": {
"whateverJson": "any JSON specific to your platform can be stored here"
}
}
Note
This is just an example — we accept all the fields listed at the top of the page.
Example
View a complete example.