A Beginner’s Guide to JSON
~ How to Properly Format a Request Body for your Messenger Bot~
1. Starts and Ends with Curly Braces
JSON always starts with an opening curly brace and ends with a closing curly brace.
2. Contains “Key-Value Pairs”
When sending information to CodelessBot, the JSON must always contain key-value pairs. For example, the screenshot below includes 2 key pairs. “first_name” and “last_name” are keys while “Dana” and “Tran” are values of those keys. Each key and its value are separated by a colon.
3. Values Can Be Assigned Manually
If you are entering in a value manually, it must be surrounded by quotation marks.
Tip: Numbers and booleans do not require quotations, but CodelessBot will accept these values even if they are surrounded by quotation marks.
4. Values Can Be Assigned a “Variable”
Instead of entering a value manually, you can also use the value of a existing custom field or user attribute.
In ManyChat, you can do this by clicking on the “Add a Variable”.
In Chatfuel, just type in {{ and a dropdown menu will appear, allowing you to select an existing attribute.
Tip: If you use a custom field or user attribute, make sure there are no quotation marks surrounding it. See example below.
5. More than 1 Key Pair? Be Sure to Add Commas
When sending more than 1 key-pair, you must separate each key-pair with a comma except for the last item. Notice in the example below that lines 2 and 3 end in a comma; line 4 does not.