# Text the caller from a Bland agent

Source: https://jointextkit.com/integrations/bland
Index: https://jointextkit.com/llms.txt

Build a Bland webhook tool that texts the person on the call a link, an
address or a confirmation through TextKit, without ending the call.

## How it works

The tool is one HTTP request to `POST https://api.jointextkit.com/v1/messages`. Bland fills
`to` with `{{phone_number}}`, the caller's number, when the tool runs. The agent
writes only `body`, the text itself. So the agent can text the person on the
call and nobody else, and you never have to read a phone number out loud or
trust the agent to copy one correctly.

The request carries your key in an `Authorization: Bearer` header, stored on
the Bland side. TextKit answers with the message (`id`, `status`), which
the agent can use to say "Sent."

## 1. Store the key as a secret

Set the sidebar selector to All agents, open Tools, and on the Secrets tab
click **Add Secret**. Name it `textkit_api_key` and paste your key
(`ssms_sk_test_...`) as a Static secret.

## 2. Build the webhook tool

Inside your agent, open Tools, click **Create tool** and choose **Webhook**.

- **Name:** `text_caller`, which is what you type after `@` in a prompt.
- **Description:** "Text the caller a link, an address or a confirmation. Use
  only after the caller agrees to get a text."
- **Agent speech:** "Sending that now."
- **Method and URL:** `POST` `https://api.jointextkit.com/v1/messages`
- **Authorization tab:** choose **Bearer Token** and pick `textkit_api_key`.
- **Body:**

```json
{
  "to": "{{phone_number}}",
  "body": "{{message}}"
}
```

Under **Detected variables**, click **Add input variable** on `message` only,
with the instructions "The full text to send, under 300 characters, with the
link or details the caller asked for." Leave `phone_number` alone: a variable
you do not add as an input resolves from the call, and `{{phone_number}}` is
Bland's built-in variable for the other party's number. Keep the `ok` output
field checked so the agent waits for TextKit's answer.

## 3. Tag it into the prompt

A tool does nothing until a prompt tags it. In the agent's Prompt, type `@`,
pick `text_caller`, and add:

```text
When the caller asks for a link, an address or a confirmation in writing,
offer to text it to the number they are calling from. If they say yes, call
text_caller with the full text, under 300 characters, and say "Sent." when it
returns. Never read the caller's number back to them.
```

## Test it in the sandbox

Use a test key (`ssms_sk_test_...`) from the [API keys](/console) page and
verify your own cell under Settings in the console. Then call your agent from
that phone and ask for the text. A test key delivers to your verified phone
for real (up to 10 a day, ending "- via TextKit sandbox"); a call from any
other phone is simulated, and the message shows in the console's log tagged
`Test · simulated`. Browser and web test calls have no caller number, so test
with a real phone call.

## Before you go live

- Swap in a live key (`ssms_sk_live_`) and [buy a number](/docs/numbers);
  with one number on the account, `from` is optional.
  [Register your use case](/docs/compliance) so carriers accept the texts.
- Have the agent offer the text and send it only after the caller says yes.
  STOP and HELP replies are handled for you ([opt-out](/docs/opt-out)).
- [Quiet hours](/docs/compliance-checks#quiet-hours) apply: a text sent
  during a call after 9pm in the caller's local time is held until 8am, unless
  it is a one-time code.
- US and Canadian numbers only. A send to any other number is refused, and the
  agent gets the error back in the tool result.

## Sources

- [Bland: Tools](https://docs.bland.ai/agents/tools)
- [Bland: Custom API tools](https://docs.bland.ai/tutorials/tools/custom-api)
- [Bland: Webhooks (built-in variables)](https://docs.bland.ai/tutorials/webhooks)
