Engati - User Guide
...
Configuring Integrations
JSON API
11 min
engati 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 i have used an api that is json based in this example, i am fetching data from an api i am storing the data from the api response in a new attribute i am 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 patch this method is used to make partial updates to existing data for the post, put, and patch methods, 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 15 seconds for using a restricted api in engati the following ips need to be whitelisted at the client side ip1 65 0 229 165	 ip2 15 206 244 196 3 response & attributes 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 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 sample apis – { "tab" "examples", "url" "https //api jsonbin io/b/60c74a4298ca6c704eaf942d", "name" "send message api –", "method" "get", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "rfhhokap9 onzmrrrpzqt", "code" "{\n \\"data\\" {\n \\"type\\" \\"text\\",\n \\"text\\" \\"your message\\"\n }\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "rfhhokap9 onzmrrrpzqt" }, "examples" { "languages" \[ { "id" "vxos9hnzyt6cpodvw6wao", "code" "curl request get\n url https //api jsonbin io/b/60c74a4298ca6c704eaf942d\n header 'accept application/json'", "language" "curl", "customlabel" "" } ], "selectedlanguageid" "vxos9hnzyt6cpodvw6wao" }, "description" "", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } { "tab" "examples", "url" "https //api jsonbin io/b/60c74b7ab274176a77e77baa", "name" "send message with options –", "method" "get", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "required", "name" "id", "type" "string", "description" "id of the cake to get" } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "i1ht8uercgjulizv6p5yt", "code" "{\n \\"data\\" {\n \\"type\\" \\"msg options\\",\n \\"text\\" \\"choose an option\\",\n \\"options\\" \[\n {\n \\"text\\" \\"option a\\",\n \\"postback\\" \\"flow 788224af8006422ba5e587720de3b252\\"\n },\n {\n \\"text\\" \\"option b\\",\n \\"postback\\" \\"flow bbc5ce0c3cd94c2da43fd6f1ae13737a\\"\n }\n ]\n }\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "i1ht8uercgjulizv6p5yt" }, "examples" { "languages" \[ { "id" "c l8ikzhtvg33v0v5f65r", "code" "curl request get\n url https //api jsonbin io/b/60c74b7ab274176a77e77baa\n header 'accept application/json'", "language" "curl", "customlabel" "" } ], "selectedlanguageid" "c l8ikzhtvg33v0v5f65r" }, "description" "", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } { "tab" "examples", "url" "https //api jsonbin io/b/60c74c44a8bf076b5f674ba2", "name" "send carousel –", "method" "get", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "required", "name" "id", "type" "string", "description" "id of the cake to get" } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "c9707ca7ht c50mxc3kdl", "code" "{\n \\"data\\" {\n \\"type\\" \\"carousel\\",\n \\"templates\\" \[\n {\n \\"title\\" \\"carousel 1\\",\n \\"subtitle\\" \\"subtitle 1\\",\n \\"image url\\" \\"https //searchengineland com/figz/800×450 jpg\\",\n \\"buttons\\" \[\n {\n \\"payload\\" \\"https //www engati com/\\",\n \\"title\\" \\"visit page\\",\n \\"type\\" \\"web url\\"\n },\n {\n \\"payload\\" \\"+11234567890\\",\n \\"title\\" \\"call a number\\",\n \\"type\\" \\"phone number\\"\n }\n ],\n \\"default action\\" {\n \\"url\\" \\"https //www engati com/\\",\n \\"type\\" \\"website url\\"\n }\n },\n {\n \\"title\\" \\"carousel 2\\",\n \\"subtitle\\" \\"subtitle 2\\",\n \\"image url\\" \\"url of image\\",\n \\"buttons\\" \[\n {\n \\"payload\\" \\"flow 788224af8006422ba5e587720de3b252\\",\n \\"title\\" \\"see another path\\",\n \\"type\\" \\"postback\\"\n }\n ],\n \\"default action\\" {\n \\"url\\" \\"https //searchengineland com/figz/800×450 jpg\\",\n \\"type\\" \\"web url\\"\n }\n }\n ]\n }\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "c9707ca7ht c50mxc3kdl" }, "examples" { "languages" \[ { "id" "cckf2enmu 8mixtyx6vq ", "code" "curl request get\n url https //api jsonbin io/b/60c74c44a8bf076b5f674ba2\n header 'accept application/json'", "language" "curl", "customlabel" "" } ], "selectedlanguageid" "cckf2enmu 8mixtyx6vq " }, "description" "", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } https //app engati com/static/standalone/bot html?bot key=de4a84a98fdb4334\&launch flow=72e48c13192f4a4cb511b74aff40c2c1\&env=p for viewing results of the sample apis in case of issues feels free to reach out to support\@engati com


