SnatchBot Support

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 docs, 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 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 Bot, then Add the Channel API:

Now Click on ADD API CHANNEL to confirm:

In Editing the API CHANNEL, the system will display you two STEPS.

  • STEP 1: How to process with the API
  • STEP 2: your API CREDENTIALS:

You are DONE.

Enjoy The SnatchBot team.

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

 

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

{

    messages: [int]string - response message

    suggested: [int]string - suggested button, if there are any

}

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 things happen.

If you have mentioned 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 one of the events is triggered, we'll send an HTTP POST payload to the webhook's

Note

We use Webhooks to send data to specified URL when some event occurs. It's POST request, it sends data about interaction, time and message text.

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

it sends a request to the server based on URL specified by the Bot creator. Presumably, your server handles them in some way.

In case you expect a reply (GET) in JSON then you could use the Interaction JSON API. It will allow you to send POST or GET requests too and offers options to send more user attributes in the request.

The main change and difference is: webhooks never expect a reply, while JSON API Interaction sends POST (or GET) requests too.

Video demonstration of Webhook