# Build, validate and test a simple flow

This tutorial demonstrates how to build, validate and test a Customer v2 flow using the [Flow editor](https://docs.ixhello.com/ixhc2/flows/flow-editor). This tutorial uses an **agent node** to **collect** a number from the user, and reply it back in a **say node**.&#x20;

After this tutorial you'll have learned how to:&#x20;

* Collect variables with an agent node
* Use those variables in a say node.
* Validate and resolve errors.
* Test the valid flow and tweak settings where needed.

## Step 1: Configure the Flow settings&#x20;

1. Sign in to **ixHello Customer v2**.
2. In the left navigation menu, go to **Flows**
3. Select **Create flow** to configure the flow settings.

<table><thead><tr><th width="272">Setting</th><th>Value</th></tr></thead><tbody><tr><td>Name</td><td>Get a number </td></tr><tr><td>Description</td><td>Collect a number between 1 and 10 and report this back to the user. </td></tr><tr><td>Persona. Text-to-Speech (TTS) language and voice</td><td>The language and voice for the app. Choose any one you desire. </td></tr></tbody></table>

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2Fjw6Dj7VhzA44z2UXMsod%2Fconfigured-settings.png?alt=media&#x26;token=aea520bb-09c6-444d-997e-1bd809c4c933" alt="Configured flow settings"><figcaption></figcaption></figure>

4. Click **Save** to create the flow and continue to the flow editor.

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FmckoSjRpusVXEN1swv3Y%2Fend-of-step1.png?alt=media&#x26;token=aa6af64b-6ec7-41aa-a03f-f1cb19084ed5" alt="Flow editor detail page for a new flow - end of step 1"><figcaption></figcaption></figure>

## Step 2: Add an agent node&#x20;

Let's add an agent node that's going to retrieve a number between 1-10 from the user.&#x20;

1. Add an Agent node to the canvas&#x20;
2. Connect it to the start node.
3. Select the agent node to open the right sidebar

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2F9FLp7dmBY1Ye29JxjEqX%2Fstep2.png?alt=media&#x26;token=12d972fe-7d7c-4097-ad23-ab0cf2afd3d8" alt=""><figcaption></figcaption></figure>

### Step 3: Configure the agent details

Configure the following agent details. The system prompt is explains what kind of agent it is, the task it needs to complete and sets some basic guards to prevent misuse.

<table><thead><tr><th width="272">Setting</th><th>Value</th></tr></thead><tbody><tr><td>Name</td><td>Collect Number</td></tr><tr><td>System prompt </td><td><p>You're a helpful assistant who will collect a number between 1 and 10 from the user. </p><p></p><p>You can't answer any other questions </p></td></tr><tr><td>Memory identifier</td><td><em>empty</em> </td></tr><tr><td>Iteration limit</td><td><em>empty</em></td></tr><tr><td>Single turn</td><td><em>Leave unchecked</em></td></tr><tr><td>Take initiative</td><td><strong>Checked.</strong> This forces the agent to send the first message when the session starts. </td></tr></tbody></table>

{% hint style="info" %}
Read more about writing effective system prompts for agents [here](https://docs.ixhello.com/ixhc2/flows/flow-editor/agent#guidelines-for-effective-system-prompts)
{% endhint %}

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2Ft1jCaPQbMpHdZoYcM1av%2Fsimple-app-step-3.png?alt=media&#x26;token=d4937a09-ebf7-4bef-8477-c9e57dab07e4" alt="configured agent details - end of step 3"><figcaption></figcaption></figure>

### Step 4: Configure the agent goal

This agent has a single goal, collecting the number between 1 and 10.

1. Select the **Add goal** field and enter the value **getNumber.** Press \<enter> or click the **+ icon** to add the goal. The **getNumber** goal is added to the agent.
   1. Enter the goal description: **Get a number between 1 and 10**
2. Select the **Add slot** field and enter the value **userNumber.** Press \<enter> or click the + icon to add the goal. The **userNumber** slot is added to the agent.&#x20;
   1. Enter the slot description: **The number the user mentioned**&#x20;
   2. Update the slot type to **Number,** since we're collecting a numeric value.&#x20;
   3. Slot is optional stays **unchecked.** This slot is required to reach the goal.&#x20;

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FlTEpJuBXnc9sRQrPbF6J%2Fstep-4.png?alt=media&#x26;token=4dad7638-785b-4a74-99d6-7d9901a16baa" alt="configured agent goals - end of step 4"><figcaption></figcaption></figure>

## Step 5: Add and configure the say node &#x20;

Let's add a say node that's going to send a message back to the user, containing the **userNumber** variable that the agent node has retrieved.&#x20;

1. Add a say node to the canvas and connect it to the getNumber exit of the agent.&#x20;
2. Open the **Say node**
3. Configure the following message: Y**ou said {{userNumber}}. Goodbye**.

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FM6KRlZePxkJCXwqApYKn%2Fstep-5.png?alt=media&#x26;token=bdb4276d-143e-4971-bb64-584bf4c254d2" alt="configured say node - end of step 5"><figcaption></figcaption></figure>

## Step 6: Add an end node and resolve errors.

1. Add an end node to the canvas, but don't connect it to the say node.
2. **Save** the flow. Your changes are saved and validated. The flow is invalid and two nodes are highlighted to help identify and resolve the problem.&#x20;
   1. The start node can't reach the end node of the flow.&#x20;
   2. The Say is missing a connection from it's exit point.

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FC9t8w28FK4OSGuMIh0Rp%2Fstep-6.png?alt=media&#x26;token=467e88d4-5b75-4f40-81a7-bc47bf372bfd" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
A validation error occurs when there are missing connections to other nodes, or required fields are empty in a node.&#x20;
{% endhint %}

3. Click on the start node to view more information about the errors.&#x20;

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FNEFHy4qKJI7D8rrJsOEN%2Fsimple-flow-6.png?alt=media&#x26;token=297f4998-3af0-47a4-8d98-7eb2c93a623e" alt=""><figcaption></figcaption></figure>

4. Let's resolve these errors by connecting the say node to the end node and click **Validate**.&#x20;

{% hint style="info" %}
This function **validates** the state of the flow on the screen, but **doesn't save** these changes to the backend. This can be seen because the feedback toaster displays **Flow is valid**, while the badge displays **Invalid.**
{% endhint %}

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2F9l2Dpdu2ilJqASbS81i7%2Fstep-6-validate.png?alt=media&#x26;token=4b639cff-ec60-4590-ae5f-bdcb62e05e9b" alt=""><figcaption></figcaption></figure>

5. **Save** the flow. Your changes are saved and validated. The badge state is updated to Valid. Let's test the flow!&#x20;

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FMEFis0zI1dSc6AW7E0x7%2Fend-of-step-6.png?alt=media&#x26;token=54253865-e4f0-4900-bb2c-af9fe51bf4ef" alt=""><figcaption></figcaption></figure>

## Step 7: Test and tweak the get number flow

1. Click the **Test** button in the top right corner and try out your Weather app!

<figure><img src="https://4187494610-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFe4cpY1jy0FJ4kgC7wSx%2Fuploads%2FKYN1WJu3khh6VsF6R5M6%2Fsimple-app-test.png?alt=media&#x26;token=9dac9b9a-fd47-4422-b87e-76dc77aeaba7" alt=""><figcaption></figcaption></figure>

Try to tweak the flow to make it your own! For example:&#x20;

* Replace **You're a helpful assistant** in the system prompt with a movie character, for example **You're Captain Jack Sparrow**, and see the effect it has on the agent's behavior.&#x20;
* Prevent an endless loop by adding an **iteration limit** to the Collect Number agent and connect your custom **Fallback** behavior to the exit that appears.&#x20;
