Skip to main content

API Access

caution

The OpenAI API has been rather flaky of late (quite understandably). For the time being, it's probably good practice for a real human to review all output before it gets used in a professional context. Otherwise you might be sending your customers API errors or timeout messages.

Query your bot

Mottle provides a simple JSON API for talking to your bot.

You will find everything you need on the Integrations Page in your account.

Sample code below:

const request = require("request");

const BOT_ID = "YOUR_BOT_ID";
const BOT_SECRET = "YOUR_BOT_SECRET";

const question = "What is your name?";

const url = `https://api.mottle.com/connect?bot=${BOT_ID}`;
const headers = { "Content-Type": "application/json" };
const data = { secret: BOT_SECRET, question: question };

request.post({ url, headers, json: data }, (err, response, body) => {
if (err) {
console.error(err);
} else {
if (body.error) {
console.log(body.error);
} else {
console.log(body.answer);
}
}
});

Email mode

To enable email mode, append &mode=email to the "Connect" API URL. For example:

https://api.mottle.com/connect?bot=1234-abcd&mode=email