SnatchBot Support

Welcome to the SnatchBot Support. You'll find comprehensive guides and documentation to help you start working with SnatchBot as quickly as possible, as well as support if you get stuck. Let's jump right in!

The community forum is not a helpdesk
Let’s put this in the front - the vast majority of people here do not work for SnatchBot.

Get Started    SNATCHBOT API
Suggest Edits

How to use the SnatchBot API

Learn everything you must require to use our API.

 

SnatchBot makes it easy to add conversational capabilities to your product or business. In these documents, you'll find everything you need to use our API.
With SnatchBot's APIs, you can create unique experiences for users at scale. There are no registration fees and our team is here to support you through the development and integration process.
SnatchBot is a software platform that enables businesses to communicate with their customers across every popular messaging app. Developers can use the SnatchBot API to add messaging and conversational capabilities to their software. Businesses can use the SnatchBot API to connect their favourite business systems and other tools to their customers over Bot messaging.
First of all, to use the API you must create a chatbot, then, having selected 'Channels', choose the Other / API option from the menu on the left:

Choose Channels, then Other/API

Choose Channels, then Other/API

You will see two tabs, API Credentials and Request configure.

The API Credentials tab has two lines for you to populate, under Your Credentials, the App ID box and the App secret box. Fill these with the App ID and App secret that you would like to use when sending and receiving requests from the chatbot.

The 'Request configure' provides you with the necessary information for setting up the other API endpoint, like Snatchbot API URLs and request parameters.

After adding the necessary credentials, you should activate the API channel by clicking the DEPLOY button above the tabs.

Now you just need to create the other API endpoint and start processing requests.

Enjoy!

Suggest Edits

Get message

 

Query Auth

 Authentication is required for this endpoint.
gethttps://snatchbot.me//bot/id<bot_id>/api<app_key>/aps<app_secret>
curl --request GET \
  --url https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E
var request = require("request");

var options = { method: 'GET',
  url:
   'https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E");

xhr.send(data);
import requests

url = "https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E"

response = requests.request("GET", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{

    archived: (1 or 0)

    date:"1970-01-01T00:00:00Z",

    direction:"string", (from_bot or to_bot)

    hasSeen:(1 or 0),

    id:int,

    isTest:(1 or 0),

    message: string, 

    userToken: string (your user id)

}

Query Params

user_id
string

user id in your application

message_id
string

id of the last message (if you don't have any messages, set message_id = 0)

 
Suggest Edits

Post message (Manual and Auto TTS generation)

 

Query Auth

 Authentication is required for this endpoint.
posthttps://snatchbot.me//bot/id<bot_id>/api<app_key>/aps<app_secret>
curl --request POST \
  --url https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E
var request = require("request");

var options = { method: 'POST',
  url:
   'https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E");

xhr.send(data);
import requests

url = "https://snatchbot.me//bot/id%3Cbot_id%3E/api%3Capp_key%3E/aps%3Capp_secret%3E"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{code:javaScript} { "cards": [ \{ "type": "image", "value": "https://dvgpba5hywmpo.cloudfront.net/media/image/YkYvDeKF6GNlpPDTiN3nDq9x2" }
],
"messages": [
{ "message": "First iter mess950086", "speech": "" },
{ "message": "2222", "speech": "" },
{ "message": "33333", "speech": "https://s3.amazonaws.com/media.snatchbot/media/audio/ba2501a2-d47b-11e9-852b-0a91dcec5994.mp3" }
],
"status": true,
"suggested": [
"urlex",
"num"
]
}{code}
{code:javaScript} { "cards": [ \{ "buttons": [], "type": "text", "value": "isTextCard" }
],
"messages": [
{ "message": "This is autogenerated tts random2\n", "speech": "https://s3.amazonaws.com/media.snatchbot/media/audio/9d01f536-d542-11e9-a66e-0a91dcec5994.mp3" },
{ "message": "aaaaaa random2\n", "speech": "https://s3.amazonaws.com/media.snatchbot/media/audio/a1dc7e00-d542-11e9-83ed-0a91dcec5994.mp3" },
{ "message": "zzzzzzz", "speech": "https://s3.amazonaws.com/media.snatchbot/media/audio/a67e5a64-d542-11e9-9aaf-0a91dcec5994.mp3" }
],
"status": true,
"suggested": null
}{code}

Query Params

user_id
string

user id in your application

message
string

message text

 
Suggest Edits

WebHooks

Use Webhooks to send data to specified URL when some event occurs.

 

A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST. A web application implementing WebHooks will POST a message to a URL when certain events happen.

If you have added a WebHook (either for your entire Bot or for a specific interaction connection), we will POST to your server each time your bot sends or receives a message.

When such an event is triggered, we'll send an HTTP POST payload to the WebHook's URL.

Note

We use WebHooks to send data to a specified URL when a particular event occurs. It is a POST request, which sends data about the interaction, the time and the message text.

A Webhook is a simple notification about an event containing data about time, userid and message text. It is sent to a specified URL.

{
"time": "2017-07-13T13:47:06.763Z'",
"data": "\"awesome\"",
"ip": "159.203.77.62"
}

The WebHook sends a request to the server based on a URL specified by you. Presumably, your server handles them in some way.

If you expect a reply (GET) in JSON then you could use the JSON API interaction. This will allow you to send POST or GET requests too and offers options to send more user attributes in the request than does a simple WebHook.

The main difference between using WebHooks and using JSON API is that WebHooks never expect a reply, while the JSON API interaction sends POST (or GET) requests and does expect a reply, which is then displayed in the conversation.

To have your chatbot send a WebHook at a particular interaction, first open the Connections tab.

Webhook for the entire Bot

You also have the option of creating a WebHook that will POST to the URL you define every time the bot sends or receives a message.

This is set on the Configure page. Choose the Bot Settings tab, and paste the endpoint URL in the “Set the Webhooks for entire bot” field, and click the Verify button.

Video demonstration of Webhook