# Building Workflows

Use the **AI Workflow Studio** to build workflows using the [**building blocks, called Nodes**](https://docs.aisera.com/aisera-platform/ai-automation-optimize-flow/ai-workflow-studio/workflow-reference-guides/workflow-nodes). This section covers how to build workflows with no code or low code (using JavaScript).

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FnWYASQOh5CkGCuC2sRzA%2Fimage.png?alt=media&#x26;token=41257db9-d79a-4e66-ba12-2c42c8ffe1b4" alt=""><figcaption></figcaption></figure>

## Create a New Workflow <a href="#pdf-page-aiu6xhwhrd2hiawxv3ph-create-new" id="pdf-page-aiu6xhwhrd2hiawxv3ph-create-new"></a>

Create new workflows from the **AI Workflows Studio** page.

#### To Create a Workflow:

1. Choose **AI Automation > AI Workflow Studio** from the left navigation menu of the Aisera Administration application (Aisera Admin UI).

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FCC81qGQ20XLVKYc1RkHK%2Fstudio1.png?alt=media&#x26;token=0e4ad642-fe3d-451c-84c3-c27923d4f72f" alt=""><figcaption></figcaption></figure>

2. Click the **+ New Workflow** button.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FlIivtg4pmzdajjV6lday%2Fstudio2.png?alt=media&#x26;token=1e176da7-23c5-4b79-adad-3db7842d280f" alt=""><figcaption></figcaption></figure></div>

2. Create a **Name** for your workflow.&#x20;
3. Select the **Scope** (Application/Bot or Tenant)&#x20;
4. Enter a **Description** that describes the purpose or result of the workflow. If you're using this workflow with a v1.0 application/bot, the description is optional. \
   \
   If you're using this workflow with a v2.0 application/bot, this field is critical. This will be used by the LLM to determine the application/bot user's Intent.\
   \
   Example: Reset Windows Password.
5. Click **OK**.

The AI Workflow Studio canvas for you new workflow is displayed.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FFJL2uoic3LO4irLKlvJf%2Fcorrected_workflow_studio.png?alt=media&#x26;token=512c9f65-531c-4f23-b4e6-278b0153c5cf" alt="" width="563"><figcaption></figcaption></figure></div>

It includes a Success message at the top, to validate that you workflow was created successfully.  Most of the Studio is the **Canvas**, where you can drag and drop **Nodes** - the components of your workflow.

After you drop a Node onto the Palette, a configuration window appears with the available options for that Node.

### Building Blocks - Workflow Nodes <a href="#pdf-page-aiu6xhwhrd2hiawxv3ph-building-blocks" id="pdf-page-aiu6xhwhrd2hiawxv3ph-building-blocks"></a>

**Nodes** are the building blocks used to build the workflow and can be found on the left pane of the visual flow studio. To use any node, select the particular node, drag and drop on the editor canvas.

You can duplicate nodes by pressing **ALT** (or the **option** button on a Mac) and then selecting a node and dragging it onto the canvas.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FcsyeKmn6eStLVNb9PFu7%2Fworkflow_nodes3.png?alt=media&#x26;token=7249a14b-18e5-4a78-a002-1a557ad5ed4e" alt="" width="375"><figcaption></figcaption></figure></div>

Details of each node are available [here](#workflow-nodes).

#### Node Order

You can't add nodes to the workflow in random order and then link them together. You can only link a new node to a previous corresponding node.\
\
Connect the nodes from each category in this order:

* **User Interaction**
  * **Message**, then **User Input** or **Input Form**
* **Operations**
* **Actions**
  * Advanced (used within **Action Nodes**)
  * API calls can also be made from within Action Nodes.

#### Compatible Nodes

When you drag a node onto the Canvas, a blue line will appear if it is compatible with the previous node. When you see the blue line, drop the node onto the canvas and you node will connect to the existing workflow.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FclYQxsCwmeH6doxjvVd3%2Fblue_line.png?alt=media&#x26;token=58ebcd41-59c4-4912-a7c1-f9e6036f3642" alt=""><figcaption></figcaption></figure></div>

In the example above, the **Message Node** has been moved onto the Canvas, and will attach to the Action Node above, after it is dropped onto the canvas.

### Save changes <a href="#pdf-page-aiu6xhwhrd2hiawxv3ph-save-changes" id="pdf-page-aiu6xhwhrd2hiawxv3ph-save-changes"></a>

Once your workflow logic is built, click the Save button. This saves your workflow in Draft mode. &#x20;

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F3M48W2coEcAeakup13LI%2Fworkflow_save.png?alt=media&#x26;token=2b1bddbe-21b3-498e-9d9a-e95136a6944b" alt=""><figcaption></figcaption></figure></div>

## Create Your First Workflow <a href="#heading-h.44sinio" id="heading-h.44sinio"></a>

This section takes you through the steps for creating a workflow that allows your application/bot users to order pizza. For simplicity, we'll use an example of a simple pizza place where customers can only order 'personal size' pizzas - one at a type. They only make 3 flavors.

Open the AI Workflow Studio by choosing **Settings > AI Automation > AI Workflow Studio** in the Aisera Admin UI.

This opens the 'drag-and-drop' interface, shown above, that lets you pull over sections of the workflow and configure them as you build a sequence for your application/bot to follow.

### Add a Few Nodes

To begin:

1. In the upper-right section of the **AI Workflow Studio** window, click the **+ New Workflow** button.
2. Enter a **Name** for your new workflow.
3. Choose whether you want the workflow to apply to a single application/bot or to all applications/bots created within the same tenant environment. The select **Application** or **Tenant** in the **Scope** pull-down menu.<br>

   <div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FxyYFTOS9vbGqI3jzGLkl%2Fworkflow_step1.png?alt=media&#x26;token=90760244-8eb1-47b4-aed5-5997326bc6c0" alt=""><figcaption></figcaption></figure></div>
4. Enter a **Description** for your workflow. \
   Remember that the description is the purpose or result of the workflow. If you're using this workflow with a v1.0 application/bot, the description is optional. \
   \
   If you're using this workflow with a v2.0 application/bot, this field is critical. This will be used by the LLM to determine the application/bot user's Intent.

#### Message Node

5. Drag a **Message Node** onto the AI Workflow Studio **Canvas** for your new workflow.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F7ptRlX2CneVO5UPKByh3%2Fdrag_message.png?alt=media&#x26;token=b35c0f59-eb16-4c7d-b18d-4e9b3c7d3d2a" alt=""><figcaption></figcaption></figure>

6. This action opens the **Message Node** window, so you can add text. If this is the first message in your workflow, it will act as the initial message in the application/bot.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FKiVJzK9lP38muvGE68cO%2Fmessage_node.png?alt=media&#x26;token=b0eb9172-0121-4a56-8bfa-dd426b4f4205" alt="" width="563"><figcaption></figcaption></figure></div>

Add an introductory message or question for your application/bot user. In this example, we're going to ask the user if they want to order pizza. But what we really want to know is what type of pizza they want to order (we assume they came to our bot to order pizza).

#### Input Node

Since we need an answer from the user about what type of pizza they want, we will add a User Input node next.

7. Drag a **User Input Node** onto your workflow canvas.
8. For this use case (pizza ordering), choose **Options List** as the **Input Type**.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FwFGSjs4tdn2tHGlaxu9H%2Finput_details.png?alt=media&#x26;token=1bf0072e-d17b-4de3-8f1f-375c422e5277" alt=""><figcaption></figcaption></figure>

9. Add **Value** and **Label** options (key value pairs) at the top of the window. These will be the choices that the application/bot users can choose between.
10. Add a **Message** that you want to display with the choices.
11. Create an **Output Variable** to store the user's choice.
12. Click the **OK** button.
13. In order to test the workflow so far, add another **Message Node** at the end.&#x20;

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FKJZ5yhjRTYNzYEdg1dfZ%2Fthird_message.png?alt=media&#x26;token=1e30d72c-466e-42c5-bd90-dd96b533bd93" alt=""><figcaption></figcaption></figure></div>

14. Now your workflow should look like this:

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fv8VjhZvzWEP47OGBMqoR%2Fsimple_flow.png?alt=media&#x26;token=8d7117f6-c341-4e8b-be2b-f65161c7a7be" alt=""><figcaption></figcaption></figure></div>

#### Test the Workflow

15. Click the **Save** button and then the **Test** button at the top of the canvas.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FSclQ4jeFWe1F6tXY1SXy%2Fworkflow_test_better.png?alt=media&#x26;token=af5d44aa-36e1-46ca-8cc9-2585bb812699" alt=""><figcaption></figcaption></figure></div>

The **Test** button runs your workflow. It is a useful tool while you are developing your application/bot sequence.\
\
The first part of the workflow runs and stops to wait for the User Input. The Input Display option is set to Buttons in our example above, so the user will see the three pizza options as buttons.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FvHDlZazt7um2PFSLf1rD%2Fchoice_buttons.png?alt=media&#x26;token=542d473a-7c10-4a24-9fd6-9fbfd85d261c" alt=""><figcaption></figcaption></figure></div>

After you choose an option, the workflow will proceed to the last message.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FB466d3EmXeiDp6N1gMdp%2Fgood_test.png?alt=media&#x26;token=513b26c5-4f29-4959-b9bc-6cc3935915b7" alt=""><figcaption></figcaption></figure></div>

This shows you that your workflow choices are working as expected, but so far nothing is going on behind-the-scenes. In other words, nothing is happening after you choose a pizza type - no order is being placed and no pizza is actually on it's way. So now you have to program what happens after the user decides on a pizza.

#### Decision Node

16. Drag a **Decision Node** onto the canvas and put it after the **User Input** **Node**. This will automatically render as a node with your choices attached. You will also see a **Default Node** below the Decision Node, where you can set a default value for the pizza choice.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F17ZlEsCygelamdGrI14l%2Fdecision_node.png?alt=media&#x26;token=e4b1e18b-9e1d-421e-b6b3-18f5eb32a7a7" alt=""><figcaption></figcaption></figure>

17. Under each leaf decision branch, drag a new user input node with a message providing the pricing for the pizza type.  \
    \
    Each new **User Input Node** should look like this following.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F67sAaB8wlXfBAVC2fySA%2Fconfirmation_pepp.png?alt=media&#x26;token=203f8e73-6ec8-46a8-8ec9-b32889fc5d9a" alt="" width="375"><figcaption></figcaption></figure></div>

18. Set the **Input Type** for each new node to **Confirmation**.
19. Set the **output parameter** value to `orderDecision`. When you're done with all 3 User Input Nodes, your graph will look like this:

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F4IlEzuwLkgGVglB2yWhG%2Fupdate_graph1.png?alt=media&#x26;token=d9219776-88a4-4bd3-a983-fde8ac0c4719" alt=""><figcaption></figcaption></figure>

20. In addition, gather the order decision as the user input value.
21. A decision node is required under each user input node to evaluate the value of the order decision variable. Based on this a custom message will be displayed. Drag and drop the Aisera Response nodes to each leaf branch.

## Import Workflows from the Workflow Library <a href="#heading-h.44sinio" id="heading-h.44sinio"></a>

Browse out-of-box workflows and add them to your application. The **Workflows Library** can be accessed from the **AI Studio Workflows** page.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FJH0bN9QG3UYKG1hMklg3%2Fimage.png?alt=media&#x26;token=8183471f-6837-4d40-8d33-0d44487e37c1" alt=""><figcaption></figcaption></figure>

## Export and import across applications <a href="#heading-h.2jxsxqh" id="heading-h.2jxsxqh"></a>

**Import** Use this option to select the workflows file to import.

**Export** Select this option to export the selected workflows and use it in another application or tenant.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FmDdlMyYqI23RXTVRisCu%2Fimage.png?alt=media&#x26;token=34e53bee-08ef-49fb-bf91-38ec84b29871" alt=""><figcaption></figcaption></figure>

### Generate Workflows from a Knowledge Base <a href="#pdf-page-aiu6xhwhrd2hiawxv3ph-generate-from-knowledge-base" id="pdf-page-aiu6xhwhrd2hiawxv3ph-generate-from-knowledge-base"></a>

You can generate new workflows automatically from your Knowledge Base articles.&#x20;

Refer to this document for details.

## **Set Message Node for Copilot Markdown Variable**

You can now use a **Workflow Message Node** to designate that the value of a variable is in Markdown format.

**To designate that the value of a variable for a Copilot application is in Markdown format:**

1. Create a new application/bot or open an existing application/bot in the Aisera Admin UI.
2. Select **AI Automation > AI Workflow Studio**.
3. Drag a **Message** node onto the **Workflow Studio** canvas.
4. Specify that the value of the variable is in Markdown format, as shown below:
