ManyChat
Submit a ticket

Dev Tools Basics

This guide is oriented to teach you about our API-tools and what you can do with Dynamic Block and External Request. Ideally, after this guide you will have a new level of understanding for these tools and will be able to resolve any problems you might encounter.

It's also important to understand that DevTools are not similar to other instruments in ManyChat. When Growth Tools and Flow Builder were created by our hands, DevTools are similar to those API-instruments that are used all around Internet.

To use them, you need to understand the basics of programming, client-server connection, API usage and API-requests structure. We'll cover all of them below.

To troubleshoot them, you need to understand all the same things and remember that problems with them are not connected to ManyChat systems by itself — those are the problems that you would find in any other similar instrument in any other service.

1. What is API (Application programming interface)?

API is a method of interaction of different apps or inside a single app. API is the base of our (ManyChat's) interaction with Facebook. There's a great documentation on API by Facebook that you can refer to for more info: [https://developers.facebook.com/docs/graph-api/](https://developers.facebook.com/docs/graph-api/)

API is used to connect with the application from outside and change/modify/send something within it. The base of API is a set of methods. Interface is characterized by methods.

2. What are nodes?

Flows consist of nodes. There's a content node (send message node). It consists of blocks. This node is what we use for sending messages to MC subscribers. We disassemble the nodes into pieces, change them into the format understandable to Facebook and send to Facebook through API.

3. What is a Dynamic Node?

It's a process when ManyChat interrupts the flow processing, goes to other actions (like an outside server request, some action, etc.) and then gets back to the flow.

4. Request consists of

1. Method or request type (GET/POST/etc),
2. link,
3. optionally - header (including API-keys and authorization),
4. optionally - body (with the content inside) if it's POST request type.

There are two things that complete the format of data in the request:
1. Protocol version that we use (currently it's v2).
2. Content: messages, actions, Quick Replies, etc. This is the exact same way as MC's content node looks. MC supports only the actions available in MC. Here they are as examples: https://manychat.github.io/dynamic_block_docs/.

Fallback option activates in case of the wrong server response in Dynamic Block — usually when the server returns an error. If an admin chooses some content in the Fallback, this content will be delivered to those subscribers for whom the request failed.

If there's no Fallback and the request fails, then the rest of the flow will not be processed and everything will stop. We recommend to use Fallback to notify users that something went wrong on the server but not to build the flow logic on it: Fallback is used in exceptional situations.

5. What is JSON path?

It's a protocol the format of which is used to extract the reply from an external system and record it in Custom Field: the server returns a response that consists of properties and their values.
Response mapping allows you to save some of the values to Custom fields by entering JSON Path to those values.
All of our integrations (Hubspot, ConvertKit) and Facebook itself uses it.

6. How are our Public API is used?

It helps to change the state of subscribers at any moment and send them messages — basically, it lets you perform certain actions from outside ManyChat. It serves for external events which ManyChat doesn't know about and about which it has to notify the subscribers. 

For example: you have a delivery service. The tracking info of the product has updated and you know whose order this is. You call the method for this specific subscriber to notify them, and they receive the message.

7. What are the POST and GET methods?

POST method changes subscriber's data, for example with "Set Custom Field", "Send Message", "Set Bot Field". POST method is also used to pass parameters to the server that are needed to perform certain actions.

Let's take the "setCustomField" API as an example — if you want to set a Custom Field to a specific value for a specific subscriber, you need to let the server know the subscriber's ID, the field's name and the value you want it to set to.

GET method is used to obtain the subscriber's or the page's info through "Get user", "Get Bot Field", etc. requests. In requests like that, we wait for a request from the external server right away. GET request doesn't have a Body.

More simple example: GET will find and return the value of Custom Field, POST will change or send the value of Custom Field somewhere.

"SendContent" method request accepts incoming messages in the same JSON format that is used for Dynamic Block: [https://manychat.github.io/dynamic_block_docs/](https://manychat.github.io/dynamic_block_docs/)

Note: POST and GET methods can be used for similar actions and requests, but it's commonly agreed that GET gets the data from somewhere and POST modifies/sends data.

8. What Dynamic Block does?

The most basic purpose of the Dynamic Block is to go to the outside server, get the JSON-code there, transform it into the message and send this message to the user.

Dynamic Block can be used for triggering our API, but it's not its main purpose, and we do not guarantee that will work correctly and our API may not return anything to Dynamic Block. Almost all requests set this way may be duplicated through the native internal interface.

An important node about using Node_Buttons: if Dynamic Block tries to reach our Public API with the code that includes the "Go To Node" button/quick reply, it will not work. Dynamic Block works inside the context of the Flow, but when it's triggering Public API, it goes out of that context and Flow will not be found.

9. What External Request does?

The most basic goal of the External Request is to go to the outside server and
1. Save some data there;
2. Change data there;
3. Get some data there and return it to ManyChat with Request Mapping.
4. Some or all of the above.

External Request can also be used to trigger our Public API with some pre-defined values inside. For example, to send the value of the Custom Field from one user to another within one bot.
Example of the notification sent like that: https://manychat.com/flowPlayerPage?share_hash=538258069985887_281a929a4f7000d731a4859e976b73cd5812f016

10. What is API Key?

It's a code used to identify the user, developer or calling program for a website. ManyChat provides API Key (PRO-feature) to use with the Account Public API. Public API Key can be found in Settings ⇒ API.

There is also a Profile Public API that's used for connection to non-bot-specific things like Templates. It requires a different key that can be found here: https://manychat.com/profile/dashboard#settings.

Troubleshooting

Specific errors and setup advice will be covered below, here we will elaborate the introduction and dig further into the troubleshooting.

1. If you don't know what's happening, google the error.
Not joking: you will often find the solution at https://stackoverflow.com/ forums or at any programming website, including Facebook Support forums; Remember that DevTools errors are not unique to ManyChat: they are common for all tools like this. Here's the list of common error status code of HTTP protocol for the orientation: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

2. It's strongly recommended to familiarize yourself with our available API requests: https://api.manychat.com/swagger#/Sending/post_fb_sending_sendContent
and JSON code examples: https://manychat.github.io/dynamic_block_docs/

Those two links are the answer to every question about possibilities of our Public API. If you cannot see a method that you are looking for, then there isn't a method like this. But you can post a feature request here: http://feedback.manychat.com/

3. You may need https://jsonlint.com/ to check that there's nothing wrong with the JSON code that our checker might have missed, but that happens rarely. Remember that you might need to disable "Encode to JSON" checkbox and there is no need to encase inserted Custom Fields into "".

What is "Encode to JSON" checkbox?
All websites have a certain protocol for accepting requests. Most of them have a tons of flags, filters and decoders that will transfer the JSON code sent from our side to something that website can understand. Some of them accept only strict JSON code. Encode to JSON allows you to transform value in the fields into JSON — that is also required when you are having only variables in the Response Body, like with {{Full Subscriber Data}}.

4. This website will allow you to check and quickly test any API request: https://learning.postman.com/docs/postman/scripts/test-scripts/

5. Links that will help you to resolve any JSON path (Request Mapping) question:

Tips and limits:

1. If you want to see how Dynamic Block works with a message from an external server, you can create your own in a matter of minutes — follow the steps in this article.

2. You can also test an API call (to ManyChat or the customer's service) in your own MC account.
If it's a POST method, you can edit the request body in your account until you find a working solution.
If it's a call to ManyChat API, you will need your own API token in the header, and if it's the customer's service that requires authorization, use the same headers that the customer set in their dev tool.

3. If the customer's server doesn't require authorization and you want to see what response it returns in a new tab, you can install a Google Chrome extension like JSON Formatter to see it structured in lines:

4. You can also copy the response from the tab or the dev tool after testing the request and use an online JSON formatter like https://jsonformatter.org/ to get it structured in lines:

It will also let you see what certain brackets belong to in the code.

5. Play around with our dev tools as much as you can to understand how they work better — try creating requests that would do the same in the MC interface, like send a message, set custom field, etc.

Things you should know:

1. Request URL’s length is limited to 2,000 symbols.

2. If you populate a CUF inside the subscriber's card, the limit is 4,000 characters. But if you save the value from the subscriber's message in Messenger with User Input, the limit is about 20,000 — it's the character limit for a message in Messenger. For API and Bot fields, there is no actual limit.

3. Timeout is limited to 10 seconds. It cannot be changed.

4. "https://" in request address is necessary in the Request URL box, even if there is a field that already contains that.

5. Request URL supports "https" only.

6. It’s not possible to map the error message if the returned code is not 200 OK and somehow react to each specific error.

7. It’s not possible to map the response values when testing the request — it’s only successful when you test the dev tool as a subscriber or preview the Flow.

8. It's only possible to map the JSON code, XML or anything like that. Other codes can be sent as a text string inside the JSON code at best, and it's only a bad workaround.

9. "\n" lets you to add line breaks to your message inside "content" > "messages".

Setup examples

1. This Flow will help to demonstrate how you can send a notification to the non-admin user of your bot: https://manychat.com/flowPlayerPage?share_hash=104787357618840_67ece64136e8b2090544e0cba8ad02d8ef9288a7

2. This Flow demonstrates how you can launch a random number generator:
https://manychat.com/flowPlayerPage?share_hash=104787357618840_3f6f0bc2789e78090d43adfa2bb1d2c82c479fce

3. You can get current subscriber's status by using this api method: https://api.manychat.com/swagger#/Subscriber/get_fb_subscriber_getInfo. You need field status in data object. Active subscriber has status = active.