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

# Call tagged contacts with an automation

> Build a Thoughtly automation that selects contacts by tag and runs an outbound voice agent campaign against them on a schedule or in response to CRM updates.

This guide explains how to recreate the "Outbound Automation" workflow. The automation lives in **Tools → Automations** and is designed to automatically call contacts that match one or more tags in your Audiences list.

Instead of uploading a CSV every time, this workflow uses a **Recurring Schedule** trigger plus a **Send Webhook** step to query the Thoughtly API for contacts that have a specific tag (for example, `Test01`). The automation then loops through the matching contacts and uses a **Call Contact** step to place outbound calls with your AI Agent.

## Use Cases

This automation is suitable for Thoughtly customers who:

* Run outbound follow‑up or nurture campaigns (not cold-calling).
* Want to periodically call a segment of warm leads or existing customers.
* Prefer to manage who should be called using tags on Contacts instead of separate upload files.
* Are comfortable using API tokens and basic Automations configuration.

## High-level flow

1. A **Recurring Schedule** trigger starts the automation (you can run it on a schedule or manually).
2. A **Send Webhook** step calls the Thoughtly `/contact` API endpoint and returns all contacts with a given tag.
3. A **Loop on Items** step iterates over the list of contacts returned by the webhook.
4. Inside the loop, a **Call Contact** step tells your chosen AI Agent to call each contact in turn.

## Prerequisites

* You have access to **Tools → Automations** in your Thoughtly workspace.
* You have at least one **AI Agent** configured and able to make outbound calls.
* You have **contacts** created in Thoughtly, and some of them are tagged with the tag you plan to target (e.g. `Test01`).
* You have an **API token** and **Team ID** from **Settings → Developer**. You’ll need these for the Send Webhook headers.
* You have an outbound phone number connected to Thoughtly (via Thoughtly Flex or BYOC) and enough credits to place calls.

## Step 1 – Tag the contacts you want to call

The automation targets contacts by tag. Before you build or run it, decide which segment you want to call and tag those contacts.

Typical examples:

* `Demo Followup`
* `No Answer – Retry`
* `Warm Lead`
* `Debt Settlement – List 1`

You can tag contacts individually on the Audiences page or include tags in your CSV when bulk-uploading. In this example, we use a test tag named `Test01`.

## Step 2 – Create the automation shell

1. In Thoughtly, go to **Tools → Automations** in the primary navigation.
2. Click **New Automation**.
3. Give it a clear name, such as **Outbound – Call Tagged Contacts**.
4. Make sure the automation is in **Draft** mode (toggle in the top‑right) while you configure it.

<Frame caption="Overall automation layout">
  <img src="https://mintcdn.com/thoughtly/iWcJydKiEz7OGghy/images/ui/automations/outbound-tagged-layout.png?fit=max&auto=format&n=iWcJydKiEz7OGghy&q=85&s=8d9212d67c6a91bf135914b3933a8550" alt="Overall automation layout — Recurring Schedule trigger at the top, then a Send Webhook step, a Loop on Items step, and finally a Call Contact step inside the loop." width="1280" height="732" data-path="images/ui/automations/outbound-tagged-layout.png" />
</Frame>

## Step 3 – Configure the Recurring Schedule trigger

1. For the trigger node, choose **Time → Recurring Schedule**.
2. In the **Configure** tab on the right, set how often it should run:
   * **How often should this run?** – e.g. `Daily`, `Weekly`, or `Monthly`.
   * **Day / Time / Timezone** – pick the time window during which you want outbound calls to start.
   * **Business Hours** – optionally restrict calls to a specific time window (e.g., 9:00 AM – 5:00 PM local time).
3. You can set a reasonable default schedule, but primarily control execution by switching the automation on and off manually if preferred.

## Step 4 – Add a Send Webhook step to fetch tagged contacts

Next, we use a **Send Webhook** action to call the Thoughtly API and retrieve all contacts that have a particular tag.

1. Click the **+** button under the Recurring Schedule node and choose **Send Webhook** from the Webhook/Utility category.

2. Select the **Send Webhook** node and go to the **Configure** tab.

3. In the **URL** field, paste a URL like the following (adjust the tag name and limit as needed):

   `https://api.thoughtly.com/contact?tags[]=Test01&limit=100&phone_numbers_only=true`

   * Replace `Test01` with the exact tag you want to target.
   * `limit=100` controls how many contacts will be returned per run.
   * `phone_numbers_only=true` ensures the API only returns contacts with valid phone numbers.

4. Set **Method** to `GET`.

5. Under **Headers**, add the authentication headers required for the Thoughtly API:
   * Key: `x-api-token` → Value: your API token
   * Key: `team_id` → Value: your Team ID

<Tip>
  **Where to find your API token and Team ID:**
  Go to **Settings → Developer** in your Thoughtly dashboard. Treat your token like a password!
</Tip>

<Frame caption="Send Webhook configuration">
  <img src="https://mintcdn.com/thoughtly/iWcJydKiEz7OGghy/images/ui/automations/send-webhook-config.png?fit=max&auto=format&n=iWcJydKiEz7OGghy&q=85&s=c6103232e292f154caa23d2499f942ba" alt="Send Webhook configuration — URL with tags[]=Test01, method set to GET, and an x-api-token header added." width="1280" height="782" data-path="images/ui/automations/send-webhook-config.png" />
</Frame>

## Step 5 – Test the webhook using the Output tab

Before wiring the loop and call steps, verify that the webhook returns the contacts you expect.

1. With the **Send Webhook** node selected, switch to the **Output** tab on the right.
2. Click **Refresh**. This will execute the webhook once using the URL and headers you configured.
3. Check that:
   * **status** shows `200` (success).
   * The **response** object contains a `data.contacts` array.
   * Each contact object includes an `id`, name, and phone number.

<Frame caption="Output tab of the Send Webhook step">
  <img src="https://mintcdn.com/thoughtly/iWcJydKiEz7OGghy/images/ui/automations/webhook-output.png?fit=max&auto=format&n=iWcJydKiEz7OGghy&q=85&s=4104ce40431a746843be0e9aa952f92c" alt="Output tab of the Send Webhook step — note the status: 200 and the response.data.contacts payload." width="747" height="895" data-path="images/ui/automations/webhook-output.png" />
</Frame>

## Step 6 – Add a Loop on Items step

Now that we can fetch the list of tagged contacts, we need to loop over them.

1. Click the **+** button under the Send Webhook node and select **Loop on Items**.
2. Select the Loop node and go to the **Configure** tab.
3. In the **Items** field, click **Insert Variable**.
4. Choose **Send Webhook → response.data.contacts** from the variable picker. This tells the loop to iterate over each contact returned by the webhook.
5. Optionally, you can set a **Limit** if you only want to call a subset of contacts per run.

## Step 7 – Add a Call Contact step inside the Loop

Inside the loop, we use a **Call Contact** step to actually place the calls.

1. Click the **+** button inside the Loop block and select **Call Contact** (Thoughtly action).
2. Select the Call Contact node and go to the **Configure** tab.
3. For **Contact**, click **Insert Variable** and choose the current loop item’s ID (for example, `Loop → item.id`). This connects the call to each contact returned by the webhook.
4. Under **Select Agent**, choose the AI Agent that should handle the call.
5. Under **Assign Genius / Knowledge Base**, choose the knowledge base that contains the script and logic for these calls.
6. (Optional) Enable **Use Custom Phone Number** and pick the outbound number you want these calls to come from.

<Frame caption="Loop on Items configured">
  <img src="https://mintcdn.com/thoughtly/iWcJydKiEz7OGghy/images/ui/automations/loop-call-contact.png?fit=max&auto=format&n=iWcJydKiEz7OGghy&q=85&s=382ec8afbecc6cd658fad61298b287ac" alt="Loop on Items configured with response.data.contacts, and a Call Contact step targeting item.id with a selected Agent." width="1229" height="603" data-path="images/ui/automations/loop-call-contact.png" />
</Frame>

## Step 8 – Turn the automation on and run test calls

1. Make sure everything is saved and the automation shows the full chain: Recurring Schedule → Send Webhook → Loop on Items → Call Contact.
2. Start with just a few test contacts tagged (e.g., 1–3 contacts) so you can safely verify behaviour.
3. When you’re ready, toggle the automation from **Draft** to **Live** in the top‑right.
4. Open the **History** tab of the automation to monitor runs, see any errors, and confirm which contacts were called.

## Nuances and best practices

* **Always test with a small internal list first** so you don’t accidentally call a large segment with an untested script.
* Consider adding post‑call logic (for example, tagging contacts as `Called` or `Do Not Call` based on outcomes) in a separate **On Call Completed** automation (scoped to one agent, multiple agents, or All Agents) or via webhooks.
* Keep an eye on your usage and any carrier‑level compliance requirements when running large outbound campaigns.
* If a run returns no contacts, double‑check that the tag name in the URL exactly matches your contact tags (including capitalization and spaces).
* You can duplicate this automation and change only the tag and agent to support multiple parallel campaigns.
