The Meta Humans bot platform provides a strong capability to integrate with any system using REST APIs with JSON as the data exchange format.
JSON (JavaScript Object Notation) is the most widely used data format for data interchange on the web.
You can easily integrate with other CRMs and your databases via this node.
-
Use an API that is JSON-based.
-
Fetching data from an API.
-
Store the data from the API response in a new attribute.
-
Displaying the data from the attribute to the end-user.
Methods
GET – This method is used to read data
POST – This method is used to update data
PUT – This method is used to write or update data
DELETE – This method is used to delete the data
For the POST and PUT method, you can use the JSON API node to make an API request to update or write data,
this data can be user-entered or predefined by the bot admin. You have to add JSON data in the Body field.
Params
-
The Params tab helps you edit the data required for URL parameters.
-
When you add key-value pairs, the JSON API Plugin automatically combines it with the URL while making the API call.
-
The value of the parameter can be user-entered or predefined by the bot admin.
If you want to pass parameters from the user’s side you will have to save the user input as an attribute in the bot and later access it in the JSON API node by typing “{“ in the Params value field.
Headers
-
You can add headers to your API request which can again be user-entered data or predefined by the bot admin.
-
You can pass authentication tokens, app secrets, passwords, and other credentials as per the requirements of the end-point.
Authentication
Authenticate allows you to define identification parameters along with the endpoint.
The authenticate tab provides you with ways to add different types of API authentication to your API request. The supported types are:
-
Key Based API Authentication.
-
Basic Authentication.
-
Token-Based Authentication (Two-Step Authentication).
You can select “None” as authentication if no authentication is required which is by default.
Key Based Auth
For requests that require Key Based API Authentication, you can simply include the authentication keys or an already saved token variable in params/headers.
Basic Auth
For Basic Authentication, you can enter your username and password. It automatically adds the required “Authorization” header to your API request.
How to use Basic Authentication:
-
In the Authentication tab, select “Basic” from the Authentication Type drop-down menu.
-
To set the authentication parameters for a request, enter your username and password or user the details from the list of variables saved.
-
Click the Send button to test your API with basic authentication.
-
In the case of an Auth failure (i.e. response code 401), it executes the path that you specify under Input Path which can be structured in a way to simply update the username/password variables.
Token-Based Authentication (Two-Step Authentication)
How to use Token-Based Authentication:
-
In the authentication tab, select “Token” from the Authentication Type options.
-
To set the authentication parameters for a request, enter the value of the token in the params, header, body or URL.
-
Create a path that would update the tokens specified as the authentication attributes.
-
Select the pathname in the Input Path field.
-
The selected path in the Input Path field is executed for updating the keys specified in case of authentication failure.
Note – JSON API Node only supports API whose responses are received in 5 seconds. For using a restricted API in the Meta Humans bot platform the following IPs need to be whitelisted at the client-side.
IP1 - 65.0.229.165 IP2 - 15.206.244.196 IP3 - 43.205.147.197 IP4 - 43.204.196.209 IP5 - 43.204.223.141 IP6 - 3.111.165.119 IP7 - 3.7.76.242 IP8 - 3.6.115.228 IP9 - 13.126.97.85 IP10 - 13.232.96.126 IP 11 - 65.0.175.128
3. Response & Attributes
The Response Section shows you the API response when hit Send after having provided the required Request URL, Params & other settings to make a valid REST API Call.
From the API response, if you wish to show certain messages to the users you can click on the object you want to show and an attribute will be created.
You can also add attributes with their values in the postback part also, we support the following ways:
{
“text”: “Select your grade”,
“postback”: “data_grade=A+”
},
data_name=John Adam
Attribute name created will be – grade
Attribute value stored will be – A+
4. JSON Response Structure
The JSON API plugin also lets you get interactive responses from your own backend server, provided the JSON response is in a specific format.
We currently support “Send Message”, “Send Message with options” and “Send Carousel” via the JSON API plugin.
If you want to display certain information from your back end as a Message, options and carousel you can use the below JSON reference code to write an API with specific responses.
In case of issues feels free to contact us at support@metahumans.ltd