Code & Webhooks

If you want to extend Bot Builder with custom code, you can call your API with webhook actions.

Recast.AI - Webhook url

You must provide a full url or route (starting with a '/') to be called by the Bot Builder, allowing you to run some codes, API calls or whatever your want :)

If you provide a route, this route will be added to your bot's base url (configurable in your bot's settings).

Recast.AI - Bot url settings

What your code will receive

You will receive a POST HTTP request on this route, with all the conversation state.

Then you can perform any calculation, database checks or extern api calls and send back data to the Bot Builder. The body format is the following:

  "messages": [],
  "conversation": {
    "id": "A_CONVERSATION_ID",
    "language": "en",
    "memory": {
      "person": {
        "fullname": "Francois",
        "raw": "Francois",
        "confidence": 0.95
    "skill": "small-talk",
    "skill_occurences": 1
  "nlp": {
    "source": "hi",
    "intents": [
        "slug": "greetings",
        "confidence": 0.99
    "sentiment": "vpositive",
    "entities": {},
    "act": "assert",
    "type": null,
    "version": "2.10.1",
    "processing_language": "en",
    "language": "en",
    "uuid": "96597974-3ee1-4743-8a5d-341b67effb9a"
    "status": 200,
    "timestamp": "2017-10-25T21:36:02.071243+00:00",

How to format your reply?

You will be able to send back a formatted message, Bot Builder will forward it to the user. Of course all messages format from Bot Connector are supported.

See more about messages format

Code example

Copy-paste this snippet in a file, install the dependencies, and run the file ;)

JS: npm install express body-parser --save

Python: pip install flask

Ruby: gem install sinatra

PHP: composer require slim/slim

const express = require('express')
const bodyParser = require('body-parser')

const app = express() 
const port = 5000 
app.use(bodyParser.json())'/', (req, res) => {

    replies: [{
      type: 'text',
      content: 'Roger that',
    conversation: {
      memory: { key: 'value' }
})'/errors', (req, res) => {

app.listen(port, () => { 
  console.log('Server is running on port 5000') 

Update the conversation memory

If you send back a new memory, all the previous memory will be replaced.