Skip to main content

API Access

Conversation mode (New)

To see an example of conversation mode, please refer to this gist on Github.

Query your bot

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

You will find everything you need on the Publish / API 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