> For the complete documentation index, see [llms.txt](https://docs.dckapintegrator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dckapintegrator.com/tutorials/workflow-builder-tutorial/2.-hello-workflow/2.5-lets-make-our-workflow-repeat-and-think.md).

# 2.5 🧠 Let’s Make Our Workflow Repeat and Think

**Scenario:** From a given array of emails, print individually if an email ends with [gmail.com](http://gmail.com) or [yahoo.com](http://yahoo.com) or not.

{% stepper %}
{% step %}

### Initialize Variable

Create a New Batch Workflow. Assume you have an array of emails. Let’s initialize a variable with the following details:&#x20;

| emails | JSON | \["<abc@gmail.com>", "<def@gmail.com>", "<xyz@company.com>", "<ijk@yahoo.com>"] |
| ------ | ---- | ------------------------------------------------------------------------------- |

***

{% endstep %}

{% step %}

### Loop through the JSON Array

Add a loop tool to iterate through the JSON Array. By default, loop through values is selected as loop type which is for loop iterating through all values. In iterable, choose from Data Hub, variables -> emails.

<figure><img src="/files/3F8AcR2AfbqoH7YTd1Om" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure Decision Step

Add a decision step inside the loop. The Decision step works like a conditional ladder — if a condition is met, that pathway runs; otherwise it checks the next condition, and so on until the else pathway. We have the ability to configure a title for each pathway. Let us have Option A for filtering emails ending with [gmail.com](http://gmail.com), option B for filtering emails ending with Ending with [yahoo.com](http://yahoo.com) and an else pathway. For each pathway to be executed, configure the condition to satisfy as shown below.

<figure><img src="/files/2XbdqWcv8vpea6botW6k" alt=""><figcaption></figcaption></figure>

If your use case demands a complex/nested condition, you can use the plus icon.

<br>
{% endstep %}

{% step %}

### Add a Console for Option A

Click on Option A of Decision Step and add a Console. The current item being considered in the iteration is accessible in the Data Hub’s item when clicking plus icon before loop.&#x20;

<figure><img src="/files/UIklIkDs7h1yI0FF67bV" alt=""><figcaption></figcaption></figure>

Configure the message as {{1.item}} ends with [gmail.com](http://gmail.com)
{% endstep %}

{% step %}

### Add a Console for Option B

For Option B, add a console with message, {{1.item}} ends with [yahoo.com](http://yahoo.com) and for else pathway, add a console with message - {{1.item}} does not end with [gmail.com](http://gmail.com)  and [yahoo.com](http://yahoo.com)
{% endstep %}

{% step %}

### Save and Run

Enable console logs and save the workflow and run. Check logs.

<figure><img src="/files/rzMJ0HTxdIaXA3uKMle3" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

#### 🎉 You have successfully used Loop and Decision together in a workflow!

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.dckapintegrator.com/tutorials/workflow-builder-tutorial/2.-hello-workflow/2.5-lets-make-our-workflow-repeat-and-think.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
