Building Transactional Flows
Introduction
Transactional Conversation Flows are interactions with the Bot that require calling one or more external web services in order to fulfil the Chat User's request.
Some examples of Transactional Flows include:
Making an appointment booking with a Customer Support Representative
Submitting an Insurance Claim
Resetting an user account's password
Converse makes it straightforward to execute custom functionality that performs performs web service calls and run computation logic by providing:
Converse Plugin SDK (Java)
Converse Middleware, which serves as a Plugin Manager to host compatible Plugins
For details on how the Plugin Architecture works and how to build custom Plugins, please see Converse Middleware Plugins
This guide provides instructions for building a Flow that provides available Hotels for a given city, an arrival date and a return date. Note: You will need the "Flights And Hotels" Plugin to be installed on the Converse Middleware to follow through this guide. This should come as standard with Demo/Sandbox Converse installation for testing purposes.
Step By Step Guide
Step Description
Example
Step 1
Navigate to the Intent Management page
Create a new Intent called "Get Available Hotels"
Step 2
Add a phrase to the intent and hit Enter
Then close the Phrase Panel
Step 3
In the first State do the following:
Change State Name to "Collect City"
Add 2 Text Message components to the State and enter in the content in the screenshot on the right
Add the Data Collection block and set the variable field to "city"
Step 4
In the Popup that appears, enter "Collect Arrival Date".
Click Save to Create the new State
Step 5
In the newly created"Collect Arrival Date" State:
Add a Text Message Component with the text: "What's your arrival date?"
Add the Data Collection block and set the variable field to "arrivalDate"
Now, follow the same process in Step 4 and create a new State named: "Collect Return Date"
Step 6
In the newly created "Collect Return Date" State:
Add a Text Message Component with the text: "What's your return date?"
Add the Data Collection block and set the variable field to "returnDate"
Now, follow the same process in Step 4 and create a new State named: "Call Service"
Step 7
Great! Now you have set up the Flow to collect all the required user inputs. Now, we will configure the Service call via Service Action block
In the newly created "Call Service" State:
Add a Service Action Block and set it up like the screenshot on the right.
Note that the Reference ID of the Service Action is set to "hotelsApi". This reference ID will be used in future steps.
Step 8
In the "Call Service" State:
Set the Text Message component's text to "Getting available hotels…" to inform the Chat User that processing is ongoing.
Step 9a
In the "Call Service" State:
Add a Transition that checks if an error has occurred in the Service Action
This is done by checking the error.message property of the Service Action exists.
If this condition is true, then the Transition will trigger.
Step 9b
Now complete setting up the Transition by specifying the Destination State to go to if the Transition's Condition is true.
Click on "+ Add New State" in the dropdown to create a new Destination State.
In the Popup that appears, enter the State Name as "Failure"
Click Save to create the new State.
Step 9c
Verify that the Transition has been set up like the screenshot on the right.
Step 10
In the "Call Service" State:
Create another Transition to check if there were no results found
To do so, check if the numHits property in the data object is equal to 0.
Note: We know there is a numHits data property because it is specified in the Plugin Function's Data Outputs (see Step 7)
Step 11
In the "Call Service" State:
Scroll to the bottom of the State Editor to find the Dialog Settings panel.
Toggle OFF Ready To Reply
This tells the Dialog Engine to evaluate the Transitions and trigger the next State without waiting for a User Input.
Step 12
Click on the "Failure" State in the Graphical Editor to edit it.
Set the Text Message component with the content shown on the right.
Step 13
Click on the "No Available Hotels" State in the Graphical Editor to edit it.
Set the Text Message component with the content shown on the right.
Step 14
Click on the "Display Hotels" State in the Graphical Editor to edit it.
Set the Text Message component with the content shown on the right.
Note: We can use the numHits property in the Text Message Component by surrounding it with a %()
Add a Dynamic Component, and set the value with the content shown on the right.
Here, we are displaying the Message Component(s) dynamically generated by the Converse Plugin Function. In this case, it is a Carousel Component containing a list of Hotels.
Step 15
Use the Admin Chat UI's Info Panel to view Data Collected or Data sent to/from Service Action
To open the panel, click on the "..." on the top-left side of the Admin Chat Header (as below).
Step 16
Activate the Intent by clicking on the "Activate Intent" button at the top-right side of the page.
The Intent Status label should now be "Active"
You're all done! You just successfully created a Transactional Flow using Service Action.
Using the process described in this guide, we can build complex conversational processes involving multiple Service calls, and weave dynamic data and static dialog content into a smooth conversational experience.
Last updated
Was this helpful?