# Workflow Best Practices

The following information was provided by Aisera Service Engineers as Best Practices for creating Workflows.

### Writing Good Titles and Descriptions <a href="#flow-titles-descriptions" id="flow-titles-descriptions"></a>

Workflow **Titles** and **Descriptions** are the key information used by the system to search and validate the relevancy of a flow to a user's Request. If they are not set up correctly, the system will not retrieve them nor validate them.

For **Titles**, use a general representation of what the workflow does.

In order to generate a correct flow description, follow these rules:

1. Describe exactly what the flow is doing. Clearly state the core use case addressed by the flow. Describe the key actions in the workflow, such as upgrade a license, troubleshoot a PC, or remove electronic access, so that the search engine can easily match the relevant keywords.
2. Provide clear, concise, and consistent information for all the expected scenarios that are covered. Avoid unnecessary details or broad statements.
3. Include relevant examples **only when necessary**, such as to highlight edge cases or customer-specific terms. This will help enhance both search and validation logic.
4. Avoid using personal names, such as, “this flow removes electronic access, for example, disable mark smith user”. Instead, use keywords like co-worker or employee.

**Example Flow**

> **Title:** MS projects and Visio provisioning
>
> **Description:** This flow addresses requests specifically for the applications Microsoft Project and/or Microsoft Visio, requests for access (or access rights/license) or upgrading/activating/reactivating a user's application's access/account/license/subscription and users' requests to download, install, reinstall and/or set up those applications OR assistance in troubleshooting the aforementioned actions. The device, if mentioned, is a computer or phone.

The description here is an amalgamation of all the phrases mentioned in the original intent. In cases where multiple scenarios are all covered by a flow, the more thorough the description, the better performance the system will provide.

**Example flow with examples**

> **Title:** Hardware Troubleshooting
>
> **Description:** This flow addresses any issue related to hardware equipment (PC, phone, PC/phone accessory/peripheral) malfunctioning or not working to the requestor's liking/convenience (such as, device not turning on, screen issues, unresponsive peripherals).

If no description is provided, the workflow will not be available in the **Intentless Flow Search**. By leaving descriptions for subflows empty, you can exclude them from the detection process. If you update the description of a prompt, you need to re-index your data, so the revised version of the prompt can be passed to the system.

### Workflow Best Practices <a href="#workflow-best-practices" id="workflow-best-practices"></a>

The best practices for Workflow creation include:

1. Always create an output variable if the JavaScript node function returns a result that affects the flow or the flow sequence. Example: for a use case where you update session variables, always declare an output variable such as `sessionVars,` as the output variable for the JavaScript node.
2. Do not use **botId** for the variable name in the flow, since this is a reserved word and may unexpectedly change the variable value in the flow runtime execution.
3. Repeated and reusable functionality should be included at a separated subflow. With this approach, your flow is more readable and you have the ability to re-use the subflow as needed.
4. Values that are used often within the flow, should be included as a separate flow variable and should be initialized at the beginning of the flow. Use the pre-built Set Variable node in this case. Some examples include base URLs and integration specific tokens. <br>

   <div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FUPupRra3OQXI01Gum4Rr%252Fimage.png%3Falt%3Dmedia%26token%3D73cae875-7d88-4559-b0ad-730509d71d39&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=a0cf46cf&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>
5. Each action that contains a `success` output variable (indication of whether the operation was successful) should be followed by a decision node based on the above `success` or `failure` result. In the case of failure, use the appropriate message node to display the error details. The following screenshot displays an example:

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FYcTimY235vW65YxuP0Wp%252Fsuccess_output_variable.png%3Falt%3Dmedia%26token%3D81f7e810-dcbf-4a42-b5d7-b74c1338cc22&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=e6f28ec&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

6. When building flows that invoke Ticket Management operations, use the pre-built ticket management actions. Review screenshots for these actions below:
   1. *Create Action Node*

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FqvWOskMo3ub0AVZPWMaV%252Fimage.png%3Falt%3Dmedia%26token%3D05902413-ff50-4bd9-878a-709e5ef57e58&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=5248b558&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

*b. Update Ticket Action*

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252F9ErdccW3adKqm6Yd3Rfs%252Fimage.png%3Falt%3Dmedia%26token%3Db99cc978-6ecc-4b94-b096-8f08ba97d19b&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=cc625847&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

*c. Get Ticket Detail*

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FlsA90VRAtNBZeQcLdlCj%252Fimage.png%3Falt%3Dmedia%26token%3D02029726-ff64-4b9f-8b2f-d525c3b16ade&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=b4b48abe&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

*d. Add Attachment Action*&#x20;

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FObk7Oi3dNn5rWDOIfqf6%252Fimage.png%3Falt%3Dmedia%26token%3D5ba73f16-fcf3-4627-804b-9c0978abba4f&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=939a628d&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

*e. List Tickets*

<div align="left"><figure><img src="https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252F6akIM16dBrlAgLPRmCrX%252Fimage.png%3Falt%3Dmedia%26token%3D0a17cfed-76df-4ace-92cd-ceed7ed8c38f&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=6dbe9c0f&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

7. If an HTTP Request should be executed within the flow, this operation is more preferable to be made by an *ExecuteRestCallAction* node. Unlike HTTP Request node, this option offers a better handling on the debugging side (logging). For this purpose:
8. A test integration should be created, that will work only as placeholder for the HTTP Request such as *Zabbix.* The integration can be configured with Test / dummy variables: ![](https://aisera.gitbook.io/aisera-product-documentation/05T7Y6PhrzglAXbQzVA8/~gitbook/image?url=https%3A%2F%2F3281977978-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FvBFXjH9S1CAy9f5hzg5Q%252Fuploads%252FaYxEg2BFs8H150b21dFq%252Fimage.png%3Falt%3Dmedia%26token%3D32ccb1d5-2a1c-47d5-a638-ca69809de98c\&width=300\&dpr=4\&quality=100\&sign=e474a7aa\&sv=2)
9. Any authorization details should be provided within the headers. An example of headers definition is provided below:

```
var headersMap = new java.util.HashMap();
headersMap.put("Authorization", "Bearer " + bearerToken);
return headersMap;
```

10. For the **User Input** node, if there is already a variable with same name defined in previous nodes, or if the **User Input** node is the leaf node, then the **User Input** node will be skipped. One exception is the **GOTO** node, which will skip the variable check logic and will ask for input variables with the same name.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aisera.com/workflow-best-practices/workflow-best-practices.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
