Support Center

Find your answer in our knowledge base

JSON API Response Formats

Use this plugin to create various integrations with your server – generate dynamic content or send data To add an attribute/user_variable to the URL field just type variable within single curly brackets {} in the URL field, such as {first_name}. Most of the time this will be auto-done for you via the “Use User Variable” field within the form. Botsify makes a simple GET or POST query to your API, then renders the response straight to the user. You can use any content-type header for this. If you are looking for an easy and fast way to set up your own endpoint for JSON plugin, check out this short tutorial. As told in this tutorial, you can use this JSON API with Stories, templates, scheduled messages or even with menu items and get started buttons Here are examples of JSON format to be used:

Here is how you can send a text message:

{
  "text": "Welcome to our store!"
}

To Send multiple packets, you can use array of objects like this:

[
  {
    "text": "Welcome to our store!"
  },
  {
    "text": "Here is the listing of your products"
  },
  ..
]

Send an image:

{
  "attachment": {
    "type": "image",
    "payload": {
      "url": "https://petersapparel.parseapp.com/img/item101-thumb.png"
    }
  }
}

Send a video*:

{
  "attachment": {
    "type": "video",
    "payload": {
      "url": "https://petersapparel.parseapp.com/img/item101-video.mp4"
    }
  }
}
* video should be in MP4 format and no larger than 20MB.

Send an audio*:

{
  "attachment": {
    "type": "audio",
    "payload": {
      "url": "https://archive.org/download/Dictaphones_Lament/TychoDictaphones_Lament.mp3"
    }
  }
}
* audio should be in MP3, OGG, WAW format, and no larger than 10MB.

Send a text card with two buttons:

{
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "button",
      "text": "Hello!",
      "buttons": [
        {
          "type": "web_url",
          "url": "https://petersapparel.parseapp.com/buy_item?item_id=100",
          "title": "Buy Item"
        },
        { 
           "type": "postback",
           "payload": "STORY_ID-0000", 
           "title": "Open" 
        }
      ]
    }
  }
}

Send a gallery:

{
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "generic",
      "elements": [
        {
          "title": "Classic White T-Shirt",
          "image_url": "http://petersapparel.parseapp.com/img/item100-thumb.png",
          "subtitle": "Soft white cotton t-shirt is back in style",
          "buttons": [
            {
              "type": "web_url",
              "url": "https://petersapparel.parseapp.com/view_item?item_id=100",
              "title": "View Item"
            },
            {
              "type": "web_url",
              "url": "https://petersapparel.parseapp.com/buy_item?item_id=100",
              "title": "Buy Item"
            }
          ]
        },
        {
          "title": "Classic Grey T-Shirt",
          "image_url": "http://petersapparel.parseapp.com/img/item101-thumb.png",
          "subtitle": "Soft gray cotton t-shirt is back in style",
          "buttons": [
            {
              "type": "web_url",
              "url": "https://petersapparel.parseapp.com/view_item?item_id=101",
              "title": "View Item"
            },
            {
              "type": "web_url",
              "url": "https://petersapparel.parseapp.com/buy_item?item_id=101",
              "title": "Buy Item"
            }
          ]
        }
      ]
    }
  }
}
Keep in mind that you can combine several messages in one answer by sending several dictionaries in the messages array.

Quick Reply

{
  "text": "testRedirectInQuickReply",
  "quick_replies": [
    {
      "content_type": "text",
      "title": "go",
      "payload": "1231414141"
    }
  ]
}
Note: Quick replies can be used with template types of responses as well. So feel free to be creative.

Postback

A new request to your JSON API can be done after clicking on a button (both Quick Reply and regular buttons are supported).
{
  "attachment": {
    "payload": {
      "template_type": "button",
      "text": "Weburl",
      "buttons": [
        {
          "url": "http://pastebin.com/raw/bYwUN7un",
          "type": "web_url",
          "title": "Open"
        },
        { 
          "type": "postback",
          "payload": "STORY_ID-0000", 
          "title": "Open" 
        }
      ]
    },
    "type": "template"
  }
}

Share and Call buttons *

{
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "generic",
      "elements": [
        {
          "title": "Classic White T-Shirt",
          "image_url": "http://petersapparel.parseapp.com/img/item100-thumb.png",
          "subtitle": "Soft white cotton t-shirt is back in style",
          "buttons": [
            {
              "type": "phone_number",
              "phone_number": "+79268881413",
              "title": "Call"
            },
            {
              "type": "element_share"
            }
          ]
        }
      ]
    }
  }
}

Receipt Format:

{
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "receipt",
      "recipient_name": "John Doe",
      "order_number": "12345678902",
      "currency": "USD",
      "payment_method": "Visa 2345",
      "timestamp": "1428444852",
      "address": {
        "street_1": "1 Hacker Way",
        "street_2": "",
        "city": "Menlo Park",
        "postal_code": "94025",
        "state": "CA",
        "country": "US"
      },
      "summary": {
        "subtotal": 75,
        "shipping_cost": 4.95,
        "total_tax": 6.19,
        "total_cost": 56.14
      },
      "adjustments": [
        {
          "name": "New Customer Discount",
          "amount": 20
        },
        {
          "name": "$10 Off Coupon",
          "amount": 10
        }
      ],
      "elements": [
        {
          "title": "Classic White T-Shirt",
          "image_url": "http://petersapparel.parseapp.com/img/whiteshirt.png",
          "subtitle": "100% Soft and Luxurious Cotton",
          "quantity": 2,
          "price": 50,
          "currency": "USD"
        },
        {
          "title": "Classic Grey T-Shirt",
          "image_url": "http://petersapparel.parseapp.com/img/grayshirt.png",
          "subtitle": "100% Soft and Luxurious Cotton",
          "quantity": 1,
          "price": 25,
          "currency": "USD"
        }
      ]
    }
  }
}
* Please note that the share button works only in gallery cards due to Facebook API constraints.

Airline templates

For airline templates, our JSON format is very similar to Facebook’s. Here is four possible airline templates’ code: