Bot messages

Bot messages are sent from the bot to the webchat endpoint. The webchat server then publishes them to the client.

Parameter Type Description
type String
Possible values:
'text' , 'table' , 'quickreplies' , 'actions'
A string representing the message type.
payload Object Object containing the message value . The Object structure changes according to the message type . See hereunder for an explanation for each type.

Text

To display a 'text', send a POST request to the webchat server endpoint (see right pane):

curl -X POST 'https://webchat.botfuel.io/bots/<APP_TOKEN>/users/<USER_ID>/conversation/messages' \
-H 'Content-Type: application/json' \
-d '{
  "type": "text",
  "payload": {
    "value": "Hello world"
  }
}'
// Response
"OK"

This will display:

webchat message text

Payload value parameters:

Parameter Type Description
value String A string containing the message.

Table

To display a 'table', send a POST request to the webchat server endpoint (see right pane):

curl -X POST 'https://webchat.botfuel.io/bots/<APP_TOKEN>/users/<USER_ID>/conversation/messages' \
-H 'Content-Type: application/json' \
-d '{
  "type": "table",
  "payload": {
    "value": {
      "schema": [
        {
          "key": "name",
          "label": "Name"
        },
        {
          "key": "job",
          "label": "Job title"
        }
      ],
      "rows": [
        {
          "name": "John Doe",
          "job": "Plumber"
        },
        {
          "name": "Jane Doe",
          "job": "Designer"
        }
      ]
    }
  }
}'
// Response
"OK"

This will display:

webchat message table

Payload value parameters:

Parameter Type Description
schema Array An array of { key, label } couples. key is a String linking a column and its rows. label is the title of the column that will be displayed in the webchat.
rows Array An array of { <KEY>: <VALUE> } objects. <KEY> is a String linking to a column key . <VALUE> is the String you want to display as a value in the table.

Quickreplies

To display 'quickreplies', send a POST request to the webchat server endpoint (see right pane):

curl -X POST 'https://webchat.botfuel.io/bots/<APP_TOKEN>/users/<USER_ID>/conversation/messages' \
-H 'Content-Type: application/json' \
-d '{
  "type": "quickreplies",
  "payload": {
    "value": [
      "Hello",
      "World",
      "Cool"
    ]
  }
}'
// Response
"OK"

This will display:

webchat message quickreplies

When the user clicks on a quickreply, it will effectively send a text message to the bot as if the user typed it.

Payload value parameters:

Parameter Type Description
value Array Array of Strings representing possible text values for the user to send.

Actions

An Action can either be:

  • A button containing a text that sends a postback message to the bot
  • A clickable link

A message of type 'actions' can contain as many Actions as you need. To display 'actions', send a POST request to the webchat server endpoint (see right pane):

curl -X POST 'https://webchat.botfuel.io/bots/<APP_TOKEN>/users/<USER_ID>/conversation/messages' \
-H 'Content-Type: application/json' \
-d '{
  "type": "actions",
  "payload": {
    "value": [
      {
        "type": "link",
        "text": "Botfuel Developer Portal",
        "value": "https://app.botfuel.io"
      },
      {
        "type": "link",
        "text": "Botfuel GitHub",
        "value": "https://github.com/Botfuel"
      },
      {
        "type": "postback",
        "text": "I want something else",
        "value": {
            "customKey": "customValue"
        }
      }
    ]
  }
}'
// Response
"OK"

This will display:

webchat message actions

Clicking on a 'link' will open a new tab with value as its URL, while clicking on a 'postback' button will send the value back to your bot endpoint. Following the last example, clicking on the last button will send (see right pane):

// Clicking on `I want something else` button will send this message to the bot endpoint
{
  "type": "postback",
  "payload": {
    "text": "I want something else",
    "value": {
      "customKey": "customValue"
    }
  }
}

Payload value parameters:

Parameter Type Description
value Array A array of Action .

Action parameters:

Parameter Type Description
type String
Possible values: 'link' , 'postback'
A String representing the Action type.
text String Label of the button if Action is of type 'postback' , text of the link if Action is of type 'link'
value Object/String Object representing a custom payload to send to the bot if Action is of type 'postback' , URL of the link if Action is of type 'link'