> ## Documentation Index
> Fetch the complete documentation index at: https://developers.scoutworks.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Power Automate and Teams

> Post each day’s new waiting-list applications to a Microsoft Teams channel, with a Power Automate cloud flow.

If your leaders use Microsoft 365, this recipe posts new waiting-list applications to a Teams channel every morning. It uses a Power Automate **cloud flow**.

<Note>
  The **HTTP** action is a premium connector. It needs a Power Automate Premium licence, or a Microsoft 365 plan that includes premium connectors. Without it, use [n8n](/recipes/n8n) or [Zapier](/recipes/zapier) for the same job.
</Note>

## 1. Start the flow

<Steps>
  <Step title="Create a scheduled flow">
    In [Power Automate](https://make.powerautomate.com), choose **Create → Scheduled cloud flow**. Call it **Scoutworks waiting list**. Set it to repeat every **1 day**, and set a start time of **07:00**. Choose **Create**.
  </Step>

  <Step title="Add the HTTP action">
    Choose **+ → Add an action**, search for **HTTP** and choose **HTTP**. Fill it in:

    * **URI:** `https://api-demo.scoutworks.app/api/v1/waiting-list?status=received&limit=200`
    * **Method:** GET
    * **Headers:** `Authorization` → `Bearer ` followed by the key, for example:

    ```text theme={null}
    Bearer sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab
    ```
  </Step>

  <Step title="Keep the key out of the run history">
    Open the HTTP action’s **Settings**. Turn on **Secure inputs** and **Secure outputs**. The run history then hides the key and the names. Do the same for the **Filter array** and **Post message** actions that you add below, because they also handle names.
  </Step>
</Steps>

## 2. Keep only yesterday’s applications

<Steps>
  <Step title="Add a Filter array action">
    Add the **Filter array** action (under **Data Operation**).

    * **From:** choose **Expression** and enter `body('HTTP')?['data']`
    * **Filter query:** choose **Edit in advanced mode** and enter:

    ```text theme={null}
    @and(greaterOrEquals(ticks(item()?['appliedAt']), ticks(startOfDay(addDays(utcNow(), -1)))), less(ticks(item()?['appliedAt']), ticks(startOfDay(utcNow()))))
    ```
  </Step>
</Steps>

This keeps the applications from yesterday, midnight to midnight (UTC). Each day has fixed edges, so a run that starts late neither misses an application nor posts one twice.

## 3. Post to Teams

<Steps>
  <Step title="Add a loop">
    Add **Apply to each**. For **Select an output from previous steps**, choose the **Body** of **Filter array**.
  </Step>

  <Step title="Post a message">
    Inside the loop, add **Microsoft Teams → Post message in a chat or channel**. Post as **Flow bot**, in your leaders’ channel. For the message, choose **Expression** and enter:

    ```text theme={null}
    concat('New waiting-list application: ', item()?['firstName'], ' ', item()?['lastName'], ' for ', coalesce(item()?['targetSection']?['name'], 'no section'))
    ```
  </Step>
</Steps>

Choose **Save**, then **Test → Manually**. The demo group has applications from many days ago, so the first test may post nothing. To see messages, change `addDays(utcNow(), -1)` to `addDays(utcNow(), -365)` for one test, then change it back.

## 4. Switch to your group

In the HTTP action, change `api-demo.scoutworks.app` to `api.scoutworks.app`, and replace the sandbox key with your own. Your key needs the `waiting-list:read` scope.

<Warning>
  The key is saved inside the flow. Anyone who can edit the flow can read it. Do not share the flow, and create a key with only the scope it needs. If you must share the flow, keep the key in Azure Key Vault and read it with the **Azure Key Vault** action instead.
</Warning>

## Limits

* **One page.** The flow reads the first 200 applications at `received`, the first stage. Once a leader moves an application on, it leaves that list. A group rarely has more than 200 at that stage.
* **Other lists.** Change the URI to read another list. The [API reference](/api-reference/introduction) lists every endpoint and field.
* **Errors.** If the key stops working, the HTTP action fails, and Power Automate emails the flow’s owner. See [Errors](/guides/errors) for what each code means.
