# 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](https://taiger.gitbook.io/taiger-converse/master/data-integrations#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                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>Step 1</strong></p><ul><li>Navigate to the Intent Management page</li><li>Create a new Intent called <strong>"Get Available Hotels"</strong></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                       | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqHooS3hELuq8rO%2F70.png?generation=1602575515313966\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 2</strong></p><ul><li>Add a phrase to the intent and hit Enter</li><li>Then close the Phrase Panel</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqI8pKwqOdVYNrW%2F71.png?generation=1602575514908871\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 3</strong></p><p>In the first State do the following:</p><ul><li>Change State Name to "<strong>Collect City</strong>"</li><li>Add 2 Text Message components to the State and enter in the content in the screenshot on the right</li><li>Add the Data Collection block and set the <em>variable</em> field to "<strong>city"</strong></li></ul>                                                                                                                                                                                                                                         | <p><img src="https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqJ492oCSIRRtzF%2F72.png?generation=1602575515354234&#x26;alt=media" alt=""></p><p><img src="https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqKkyplSg1S6LwP%2F73.png?generation=1602575515316775&#x26;alt=media" alt=""></p> |
| <p><strong>Step 4</strong></p><ul><li>In the Graphical Editor, click on the <img src="https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqLR4PmyxliBM6R%2F74.png?generation=1602575514915849&#x26;alt=media" alt="">button in the under the State Node</li><li>In the Popup that appears, enter "<strong>Collect Arrival Date</strong>".</li><li>Click Save to Create the new State</li></ul>                                                                                                                              | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqMYKStESeA_Oxc%2F75.png?generation=1602575515326555\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 5</strong></p><ul><li>In the newly created<em>"Collect Arrival Date"</em> State:</li><li>Add a Text Message Component with the text: <strong>"What's your arrival date?"</strong></li><li>Add the Data Collection block and set the <em>variable</em> field to "<strong>arrivalDate"</strong></li></ul><p>Now, follow the same process in Step 4 and create a new State named: "<strong>Collect Return Date</strong>"</p>                                                                                                                                                               | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqNXDclWDm2kDMM%2F76.png?generation=1602575515312711\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 6</strong></p><p>In the newly created <em>"Collect Return Date"</em> State:</p><ul><li>Add a Text Message Component with the text: <strong>"What's your return date?"</strong></li><li>Add the Data Collection block and set the <em>variable</em> field to "<strong>returnDate"</strong></li></ul><p>Now, follow the same process in Step 4 and create a new State named: "<strong>Call Service</strong>"</p>                                                                                                                                                                          | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqOUx0hMJp3U8wl%2F77.png?generation=1602575515368075\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 7</strong></p><p>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</p><p>In the newly created <em>"Call Service"</em> State:</p><ul><li>Add a Service Action Block and set it up like the screenshot on the right.</li><li>Note that the Reference ID of the Service Action is set to "<strong>hotelsApi</strong>". This reference ID will be used in future steps.</li></ul>                                                                                                               | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqPGWAG4b58CGXJ%2F78.png?generation=1602575515309395\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 8</strong></p><p>In the <em>"Call Service" State:</em></p><ul><li>Set the Text Message component's text to "<strong>Getting available hotels…</strong>" to inform the Chat User that processing is ongoing.</li></ul>                                                                                                                                                                                                                                                                                                                                                                   | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqQEa8F0SG-W7NQ%2F79.png?generation=1602575515329945\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 9a</strong></p><p>In the <em>"Call Service" State:</em></p><ul><li>Add a Transition that checks if an error has occurred in the Service Action</li><li>This is done by checking the <strong>error.message</strong> property of the Service Action exists.</li><li>If this condition is true, then the Transition will trigger.</li></ul>                                                                                                                                                                                                                                                | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqRgDEjJf1ts2cd%2F80.png?generation=1602575515314223\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 9b</strong></p><p>Now complete setting up the Transition by specifying the Destination State to go to if the Transition's Condition is true.</p><ul><li>Click on "+ Add New State" in the dropdown to create a new Destination State.</li><li>In the Popup that appears, enter the State Name as "<strong>Failure</strong>"</li><li>Click Save to create the new State.</li></ul>                                                                                                                                                                                                       | <p><img src="https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqSfzaeHe-dXQH6%2F81.png?generation=1602575515331888&#x26;alt=media" alt=""></p><p><img src="https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqTsxhCjku8eRFf%2F82.png?generation=1602575515311031&#x26;alt=media" alt=""></p> |
| <p><strong>Step 9c</strong></p><p>Verify that the Transition has been set up like the screenshot on the right.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqU70ZXFyJrf6Pv%2F83.png?generation=1602575515311012\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 10</strong></p><p>In the <em>"Call Service" State:</em></p><ul><li>Create another Transition to check if there were no results found</li><li>To do so, check if the <em>numHits</em> property in the data object is equal to <strong>0</strong>.</li><li>Note: We know there is a <em>numHits</em> data property because it is specified in the Plugin Function's Data Outputs (see Step 7)</li></ul>                                                                                                                                                                                   | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqV4krbkp15Sq4A%2F84.png?generation=1602575515310404\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 11</strong></p><p>In the <em>"Call Service" State:</em></p><ul><li>Scroll to the bottom of the State Editor to find the Dialog Settings panel.</li><li>Toggle <strong>OFF</strong> Ready To Reply</li><li>This tells the Dialog Engine to evaluate the Transitions and trigger the next State without waiting for a User Input.</li></ul>                                                                                                                                                                                                                                               | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqWvFNXWZ91ftNo%2F85.png?generation=1602575515322940\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 12</strong></p><p>Click on the "<em>Failure</em>" State in the Graphical Editor to edit it.</p><p>Set the Text Message component with the content shown on the right.</p>                                                                                                                                                                                                                                                                                                                                                                                                               | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqXDZg7gpHApyCx%2F86.png?generation=1602575515330650\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 13</strong></p><p>Click on the "<em>No Available Hotels</em>" State in the Graphical Editor to edit it.</p><p>Set the Text Message component with the content shown on the right.</p>                                                                                                                                                                                                                                                                                                                                                                                                   | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqY87A_s2db24VF%2F87.png?generation=1602575515308793\&alt=media)                                                                                                                                                                                                                                                      |
| <p><strong>Step 14</strong></p><p>Click on the "<em>Display Hotels</em>" State in the Graphical Editor to edit it.</p><p>Set the Text Message component with the content shown on the right.</p><p>Note: We can use the <em>numHits</em> property in the Text Message Component by surrounding it with a <code>%()</code></p><p>Add a Dynamic Component, and set the value with the content shown on the right.</p><p>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.</p> | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqZ3KKNdmj30Xwm%2F88.png?generation=1602575515324098\&alt=media)                                                                                                                                                                                                                                                      |

**Step 15**

Test the flow! Scroll up to the Intent Header, and click on the ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIq_eWLoB_tMHxV_%2F89.png?generation=1602575514929389\&alt=media)Quick-Test icon on the right side of the Intent Name.

![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqadVzttH7ag3YL%2F90.png?generation=1602575515327058\&alt=media)![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqbpbZLE8qu28uk%2F91.png?generation=1602575516373221\&alt=media)

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).

![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqcy4qpWq_BhJUF%2F92.png?generation=1602575515322361\&alt=media)

| ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqdNc0iql9on1mO%2F93.png?generation=1602575515325294\&alt=media) | ![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqekfrbHLKozFRs%2F94.png?generation=1602575515321310\&alt=media) |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

**Step 16**

**Activate the Intent** by clicking on the "Activate Intent" button at the top-right side of the page.

![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqfxvd6YGMr_WqK%2F95.png?generation=1602575514934151\&alt=media)

The Intent Status label should now be "Active"

![](https://1381196040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Ftaiger-converse%2F-MJVuHz_bCDmA218kKwc%2F-MJVwIqgK1Z5j4NJ2Ug_%2F96.png?generation=1602575515324765\&alt=media)

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.
