Use the integration action when you want to call an HTTP integration endpoint to achieve some custom business needs. You can process the parameters saved during the life cycle of the assistant, and either only store them out in some other system for later usage, or even modify the flow of the assistant by pushing some messages or cards after that action or force it to fallback.
The story begins by drag and drops (Or simply click on) the Integration action from the actions menu in the left side to your assistant design canvas:
After that, you will need to click on the action to configure its needed parameters, you will need to configure basically the URL of your integration endpoint, the connection of the next coming action, and the fallback action. And optionally you can put a name, choose the request method, choose the authorization type, choose the parameters that will be read from the response and put some comments for your action as next:
To clear things more, I will make a small scenario with that action, my assistant will ask for a product name from the user and it will fetch all comments related to that product. I will use an Amazon AWS Lambda function to implement the integration endpoint. My assistant will look like next:
The assistant will start with a welcome message, then will ask the user to put the product name he wants to fetch its comments, then the input action will get the product name from the user and store it inside a parameter. And while all the parameters will be sent with integration action to my endpoint I will use that product name to query for its comments. I will write my Lambda function as next:
The Lambda function will start by validating the data coming from the assistant, make a call to some endpoint that returning the comments, and then formatting the response that suits the integration action in this part of code:
And in case of fallback, the Lambda function will call the fallback function defined as next to tell the integration action to fallback.
The integration action will push the messages returned by my Lambda function to the assistant so the user will see a list of product comments messages appeared after he put the name of the product:
Finally, the assistant will ask the user if he wants to repeat the query or just end the conversation.
So this is a very simple scenario that shows how you can deal with integration service, but for sure the door is opened for any business logic you can think about or you need. Also, you can use any integration point whether its a container backend point, a code in a VM, any serverless function while it supports the HTTP POST method, and returns the result in "application/json" content type.
Some endpoints support specific type of authorization layer. In this action we are supporting some common ways for authorization in order to authorize the call to these endpoints, they are as next:
In some scenarios and if the endpoint is not returning the format Mindbehind is waiting for, you can access the response variables using "Variables" section and convert them into a bot parameters. The cool thing here is that you can access any deep variable using dot operations or even items inside array using indexes. Next you can see an example of that:
So we have an endpoint that is returning variants of a product, so let's say we need to save the product id and the cheapest variant price in bot parameters as next:
Please note: That for now we are just supporting JSON response type
Integration action is used to call an integration endpoint with the HTTP POST method, sending the following parameters in the body of the message:
And the flow will continue using the integration action connection normally unless the integration endpoint returned NULL result or it includes fallback set to true, then the action will fallbacks.
If you didn't configure a fallback for your action, your assistant will stop responding in case you force fallback or your endpoint failed to work for any reason and returned an error.
Defining a delay for this action will delay the call to integration endpoint concluding delays in the upcoming messages after the integration action.
Note: Integration action will not respond to connect messages coming from channels.
Integration action supports the ability to push dynamic messages programmatically, which will be returned in the "modules" parameter in the response of integration endpoint.
The "modules" parameter is an array that can contain different messages objects, in order to know more about messages format and their properties please review them in the next article: