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.
You may specify your own custom JSON body, such as { “a”: “{user_name}”, “b”:”hello” }; note that fields will be converted. If no body is specified, SmartBot360 will pass to the specified external API a JSON object that contains:
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.
All non-user profile fields collected by the bot so far, e.g., insurancename.
The API is expected to return either:
a 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.
OR
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.
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.
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.
Tip
You can set input 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.
Advanced
If a returned 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”.