# Lesson #1: Build your first flow

By the end of this lesson, you will have configured your first integration and built a fully automated weekly newsletter about airport lounges — from data fetching to your inbox.

## Prerequisites

- A Mindflow account with access to your workspace ([Sign in](/getting-started/sign-in/)).
- A [NewsAPI](https://newsapi.org/) account and API key.

## Step 1: Configure your NewsAPI Credential

Connect Mindflow to NewsAPI — the service we will use to programmatically collect news articles from around the world.

First, retrieve your API key:

1. Go to [newsapi.org](https://newsapi.org/) and click **Get API Key**.

   <div class="docs-screenshot-compact">

   ![Go newsapi org click get api](./assets/go-newsapi-org-click-get-api.png)

   </div>

2. Create an account and complete the process. Your API key will be displayed at the end. **Keep it safe** — treat it like a password.

   <div class="docs-screenshot-compact">

   ![Create account complete process](./assets/create-account-complete-process.png)

   </div>

Now, create the credential in Mindflow, to do first you need to **activate the integration News API:**

1. Open the **Integration** tab in the platform.

![Image without caption](https://image-forwarder.notaku.so/aHR0cHM6Ly9maWxlLm5vdGlvbi5zby9mL2YvNTU2NDNiOTAtNzQzNC00MjI4LWEwYjktNWRhMGQyYjgzYWFmLzZmMzMyOGZhLTI4MGYtNDMxMS1iMjFlLTZmMGI1ZjcxOGIxYy9TY3JlZW5zaG90XzIwMjYtMDMtMDVfYXRfMTkuNTMuMzcucG5nP3RhYmxlPWJsb2NrJmlkPTMxYTkzYTA4LTBhYjAtODAwYy04MTMyLWY0MDE1MzQ0ZDQ0YyZzcGFjZUlkPTU1NjQzYjkwLTc0MzQtNDIyOC1hMGI5LTVkYTBkMmI4M2FhZiZleHBpcmF0aW9uVGltZXN0YW1wPTE3NzgxNTQ4MDcyOTEmc2lnbmF0dXJlPW1ILVZ1MWpoM0xnWHM3bEFSYUlCazBmRDU1SzByTU5BbVgzbU9GWTlnS1k=.png?workspaceId=55643b90-7434-4228-a0b9-5da0d2b83aaf)

1. Use the **search bar** to find the vendor.

   <div class="docs-screenshot-compact">

   ![Use search bar find vendor](./assets/use-search-bar-find-vendor.png)

   </div>

1. Select the **service** you want and turn on the integration using the **switch** in the top‑right corner.

   <div class="docs-screenshot-compact">

   ![Select service you want turn integration](./assets/select-service-you-want-turn-integration.png)

   </div>

Then you will be able to create the credential:

1. Navigate to **Environments** in the left-hand sidebar.

   <div class="docs-screenshot-compact">

   ![Navigate environments left hand sidebar](./assets/navigate-environments-left-hand-sidebar.png)

   </div>

2. Open the Environment where you want to store the credential (your personal Environment or the Global one).
3. Click **Create a credential** (or the **+** icon if credentials already exist).

   <div class="docs-screenshot-compact">

   ![Click create credential icon if credentials](./assets/click-create-credential-icon-if-credentials.png)

   </div>

4. Configure the credential as follows:
   - **Service:** Select **NewsAPI** from the list of native integrations.
   - **Credential name:** Give it a recognisable name (e.g., `NewsAPI - [Your Name]`).
   - **Address:** Paste the NewsAPI URL (e.g., [`https://newsapi.org/v2`](https://newsapi.org/v2) ).
   - **API Key:** Paste the API key you retrieved from NewsAPI.

   <div class="docs-screenshot-compact">

   ![Api key](./assets/api-key.png)

   </div>

5. Click **Create**.

Your NewsAPI credential is ready!

---

## Step 2: Create your Flow

On the far right of the Mindflow interface, click the **Create** button and select **Flow**.

   <div class="docs-screenshot-compact">

   ![Click create](./assets/click-create.png)

   </div>

Name your flow (e.g., `Airport Lounges Newsletter`) and select the Environment where you stored your credential. Click **Create** — you will be redirected to a blank canvas.

   <div class="docs-screenshot-compact">

   ![Click create](./assets/click-create-2.png)

   </div>

---

## Step 3: Add a Scheduler Trigger

On Mindflow, every Flow can be triggered in multiple ways:

- **Webhook**: This is the most common use case. You will configure a third-party to react on specific events and send the data to another service, Mindflow in this instance. This goes through what is called a “Webhook URL”. Whenever you create a Webhook Trigger step, if you open its settings tab, you will see two URLs. These are two types of Webhook URLs. We will come back on the difference in another Training.
- **Emailhook**: In some cases, you will want to trigger a flow with something else than a Webhook (third-party tool limitation, direct mail ingestion, or else). Whenever you create a Emailhook Trigger, you generate a unique email address to which you can send email to (Beware, you may need to ask for sender domain whitelisting to MIndflow!).
- **Flowhook**: This will be needed to create Swarms in Mindflow. It incredibly powerful and we will get back to this in another Training.
- **Scheduler**: This is the one we will use today. You can direct a Flow to automatically start itself through this Scheduler Trigger.

For this use case, we want the flow to run automatically once a week.

1. Click **Add a step manually** on the canvas.

   <div class="docs-screenshot-compact">

   ![Click add step manually canvas](./assets/click-add-step-manually-canvas.png)

   </div>

2. Select **Scheduler**.

   <div class="docs-screenshot-compact">

   ![Select scheduler](./assets/select-scheduler.png)

   </div>

3. Open the step's settings tab (⚙️) and configure it:
   - **Scheduler:** At regular interval
   - **Frequency:** Weekly
   - **On:** Select the day(s) of your choice
   - **At / Minutes:** Set the time you want the flow to run

   <div class="docs-screenshot-compact">

   ![Minutes](./assets/minutes.png)

   </div>

---

## Step 4: Compute Last Week's Date with Transform Data

Before fetching articles, we need to calculate the date from 7 days ago to limit our query to recent news. The **Transform Data** step is your go-to for generating or modifying data within a flow.

1. Add a **Transform Data** step below the Scheduler.

   <div class="docs-screenshot-compact">

   ![Add transform data step below scheduler](./assets/add-transform-data-step-below-scheduler.png)

   </div>

2. Rename the default variable (click the dotted rectangle) to `from_date`.
3. Click the **fx** button on the value field to open the **Data Transformation module**.

   <div class="docs-screenshot-compact">

   ![Click fx button value field open](./assets/click-fx-button-value-field-open.png)

   </div>

4. Chain the following three functions:
   - **Get Time** _(Date & Time)_: Returns the current time as a UNIX timestamp.

   <div class="docs-screenshot-compact">

   ![Get time](./assets/get-time.png)

   </div>

   - **From UNIX Timestamp** _(Date & Time)_: Converts the timestamp into a human-readable date.

   <div class="docs-screenshot-compact">

   ![Unix timestamp](./assets/unix-timestamp.png)

   </div>

   - **Modify date with duration** _(Date & Time)_: Subtracts 7 days.
     - Click **Advanced** and enable **Days to adjust**.
     - Set **Operator** to **Subtract**.
     - Set **Days to adjust** to `7`.

   <div class="docs-screenshot-compact">

   ![Set days adjust](./assets/set-days-adjust-7.png)

   </div>

The module will auto-evaluate at each step so you can verify the result in real time. Your `from_date` variable is set!

---

## Step 5: Fetch News with the NewsAPI Step

Now that we have our date, let's pull the latest articles.

1. Add a **NewsAPI** step below the Transform Data step. You will select the `Search all articles` endpoint.

   <div class="docs-screenshot-compact">

   ![Add newsapi step below transform data](./assets/add-newsapi-step-below-transform-data.png)

   </div>

2. Open the step's **Settings** tab (⚙️) and assign the NewsAPI credential you created in Step 1.
3. Switch to the **Configuration** tab and set the following parameters:
   - Activate both `Q` and `From` parameters through `Advanded` button
   - **Q** _(query)_: `best airport lounges`
   - **From:** Type `/` to open the **Data Picker**, then select the `from_date` variable you created in Step 4. This creates a **Data Pill** — a dynamic reference that will evaluate and inject the correct date on every run.

   <div class="docs-screenshot-compact">

   ![From](./assets/from.png)

   </div>

4. Click the **▶️ (Play)** button next to the step to **Dry run** it.

Once the pill turns green, the step ran successfully! Open the execution log (click the green pill or switch to the Logs tab) to inspect the response. You will find a `body` object containing `totalResults` and `articles` — an array of news article objects. Familiarise yourself with the **JSON Viewer**, then close the log.

   <div class="docs-screenshot-compact">

   ![Click play button next step dry](./assets/click-play-button-next-step-dry.png)

   </div>

---

## Step 6: Summarise Articles with an AI··Task

In Mindflow, **AI··Tasks** are agentic steps that can generate outputs, call APIs, and orchestrate sub-agents. Here, we will use one to turn raw article data into a polished HTML newsletter.

1. Add an **AI··Task** step below the NewsAPI step.
2. Open the configuration tab and set:
   - **Model:** Choose your preferred LLM (e.g., Claude or GPT).
   - **Prompt:** Type the following instruction, then type `/` to open the Data Picker. Select the **articles** array from the NewsAPI step's last execution — this creates a Data Pill that will inject the articles at runtime.

   ```markdown
   Provide a detailed summary of the following news articles. Not all of them may be relevant to my subject, which is: airport lounges.
   Answer, as a newsletter, with a nicely crafted HTML content.
   Include embedded URLs of selected articles.
   Only reply with the HTML, no backticks encapsulation.

   News: [articles Data Pill]
   ```

   <div class="docs-screenshot-compact">

   ![Prompt](./assets/prompt.png)

   </div>

3. Click **▶️** to Dry run the step. Once complete, open the log — the result will be a ready-to-send HTML newsletter!

   <div class="docs-screenshot-compact">

   ![Click dry run step](./assets/click-dry-run-step.png)

   </div>

:::note
**Tip:** Click the 👁️ icon above the prompt field to preview the resolved value of your Data Pills.
:::

---

## Step 7: Send the Newsletter by Email

The final step delivers the AI-generated newsletter straight to your inbox.

1. Add a **Send Email** step.
2. Configure it as follows:
   - **From:** Leave as default, or customise the prefix.
   - **To:** Enter your email address (add more recipients with **Add item**).
   - **Subject:** e.g., `✈️ Airport Lounges Weekly`
3. Click **Advanced** in the top right of the panel and enable **HTML**.

   <div class="docs-screenshot-compact">

   ![Click advanced top right panel enable](./assets/click-advanced-top-right-panel-enable.png)

   </div>

4. In the **HTML** field, type `/` to open the Data Picker. Navigate to the AI··Task step, select the last execution, and pick **Results** from the JSON Viewer.

   <div class="docs-screenshot-compact">

   ![Html field type open data picker](./assets/html-field-type-open-data-picker.png)

   </div>

5. Dry run the step and check your inbox — your HTML newsletter should arrive within seconds!

   <div class="docs-screenshot-compact">

   ![Dry run step check your inbox](./assets/dry-run-step-check-your-inbox.png)

   </div>

---

## First Flow — Complete

Congratulations! You have built your first end-to-end automated flow on Mindflow.

Every week, this flow will automatically fetch the latest airport lounge news, use AI to curate and format the content, and deliver a beautiful HTML newsletter to your inbox — without any manual intervention.

Ready to see it run in full? Click the **▶️ Play** icon in the top left of the canvas, or press **⌘+P** (or **Ctrl+P** on Windows).

In [Lesson #2: Process lists with AI](/learn/l2-process-lists-with-ai/), you will go further: handling lists of data with For Each loops, empowering AI··Tasks with external tool calls, and parsing complex API responses.
