---
name: thoughtly-agent-workers
description: Build and test hosted Thoughtly call automations. Use when a CRM or form should trigger calls to opted-in leads, a caller needs a live lookup, or a completed call should update a record while the owner's agent is offline.
---

# Thoughtly Agent Workers

With [Thoughtly for Agents](https://agents.thoughtly.com/), you can build and test a phone workflow for your user. Thoughtly hosts the worker so it can respond to future events or run code during a call. For example, the [HubSpot callback recipe](https://agents.thoughtly.com/recipes/hubspot/call-demo-request/markdown) calls a lead who requested a callback and saves the outcome to their contact record. For a single requested phone call, use `place_call` directly.

Use the connected Thoughtly origin, or `https://agents.thoughtly.com` for the public service. Check `POST /v1/workers` in its `/openapi.json`. If disabled, prepare the handler and fixture as a draft. [MCP setup](https://agents.thoughtly.com/docs#mcp)

## Choose the handler

| User’s request | Recipe |
| --- | --- |
| “Call each lead who checks ‘call me’ on our form.” | The source supplies the phone number, opt-in and a stable event ID. [Lead webhook](https://agents.thoughtly.com/recipes/crm-trigger-call.md) |
| “Check Friday availability while the caller waits.” | Bind a read-only tool and wait for its result before speaking. [Live lookup](https://agents.thoughtly.com/recipes/live-tool-lookup.md) |
| “Start the sync while I keep talking.” | Queue the work and report completion when its result arrives. [Background tool](https://agents.thoughtly.com/recipes/background-call-tool.md) |
| “Log the outcome of each call this worker starts.” | Carry the original record ID through and key the write by call ID. [CRM writeback](https://agents.thoughtly.com/recipes/post-call-crm.md) |

Use `find_recipes` for provider-specific examples. Connect a CRM with `connect_mcp` only when the handler needs a read or write. Use `get_mcp_connection` to select the actual remote tool and its arguments.

## Test and activate

1. Use `get_pricing` and `create_worker` to draft the handler with the owner’s limits. The daily cap covers compute. Each call has its own maximum. For a lookup-only worker, set `max_call_cost_usd` to `"0"`.
2. Run `test_worker` with a fixture when the user authorizes metered testing. It uses prepaid compute and simulates external actions. For lead callbacks, verify that an opted-in event proposes one call and an opted-out event skips it. Reuse a test’s idempotency key only with the same payload.
3. After the owner approves activation and the applicable costs, call `set_worker_state` with `state: "active"` and `accept_costs: true`. For a source webhook, bind its trigger secret in the source’s secret store and connect the selected event.
4. Read `get_worker_run` to report the real outcome. On redelivery, reuse the source event ID and body. If a CRM write has an unknown outcome, check the target record before retrying.
