← Back to table of contents

External API Integration

This is an advanced feature only available in Enterprise plans. If you have an Enterprise plan and want to use this feature, email customerservice@smartbot360.com to have this feature enabled in your account.

This Bot Builder box is useful when you want to call an external API (via a POST request) when the chat reaches a specific state. For example, you may want to write the user responses to an external database. This box also allows the API to set user profile field values and/or save the returned response into a variable.

Specifically, SmartBot360 will pass to the specified external API a JSON object that contains:

  1. All user profile fields, including built-in ones like user_fname, user_lname, user_phone, user_city, and user profile fields collected by the bot like user_concern.

  2. All non-user profile fields collected by the bot so far, e.g., insurancename.

The API is expected to return either:

  • an JSON object with a set of user profile fields and non-user profile fields. These returned values will overwrite the current values of these fields in the bot execution. If the returned JSON contains a key that is not already a variable in the chatbot, a new custom variable will be created.

  • a String

Go to CHATBOTS to create a Flow Diagram bot. Insert the External API box where you want it to be called. Specify the URL that will be used to make a POST request.

Screenshot from 2020-07-21 14-16-05.png

Below is an example of an API JSON response that follows the correct format, where the key is a user profile field or a non-user profile field name (if not, a new non-user profile field will be created), and the value is the value to assign to this field. If the key is a system (restricted) user profile field (such as SDFuserid, password) then the key will be prefixed with “API”. For example, if the key is SDFuserid which is a restricted user profile field then the key will be “APISDFuserid”.

icons8-api-96.png
Example of a valid API response for the External API box

You may check that the values have been indeed updated by adding a Message box with message {lead} on the Success path, which should display “Yes” for the above example, when the bot is executed.

If the external API inputs parameters, you can set their values using Set Field Value boxes, before the External API box. For example, you can add a Set Field Value to set the variable securitytoken to 123456, if this input is required by the POST call.