> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# Amazon Bedrock SWAIG tool webhook

POST 

Sent to a tool's `web_hook_url` (or the SWAIG `defaults.web_hook_url`) when an
[`amazon_bedrock`](/docs/swml/reference/calling/amazon-bedrock) agent calls one of your functions.
Your endpoint runs the function and replies with a JSON object. Both fields are optional, so `{}`
is a valid reply:

* `response` — the result the agent reads next. A plain string only here; the
  `{tool_result, tool_prompt}` object form that [`ai`](/docs/swml/reference/calling/ai) agents
  accept is not read. Omit it and the agent reads a default result.
* `action` — a single action object or an array of them, executed on the live call.

There is no `post_process`: a Bedrock agent always defers actions until after it has spoken.

Bedrock agents send a different payload from [`ai`](/docs/swml/reference/calling/ai) agents. Notably
`content_type` is `text/json` rather than `text/swaig`, `argument` carries no `substituted` value,
there is no `version`, `description`, or `argument_desc`, and the call's timing and caller fields
are named differently. Write your handler against this payload, not the
[AI SWAIG tool webhook](#tag/calls/webhook/aiSwaigToolWebhook).

Reference: https://signalwire.com/docs/apis/rest/webhooks/bedrock-swaig-tool-webhook

## Request

### Payload

- `function` (string, required) — The name of the function the agent is calling.
- `argument` (object, required) — The arguments the agent passed to your function.
  - `parsed` (list of object, required) — The arguments parsed into objects. Usually a single-element array.
  - `raw` (string, required) — The raw argument string, exactly as the agent produced it.
- `call_id` (string, required) — The ID of the call.
- `ai_session_id` (string, required) — The ID of the AI session on the call. Matches `call_id` for Bedrock agents.
- `app_name` (string, required) — The name of your Bedrock application. Defaults to `bedrock`.
- `caller_id` (string, required) — The caller's number. An empty string when the call has none.
- `global_data` (object, required) — The agent's current `global_data`. Alongside anything you seeded, the session adds `caller_id_name` and `caller_id_number` when the call carries them.
- `content_type` (string, required) — The content type of the request body. Always `text/json`.
- `content_disposition` (string, required) — How the body is delivered. Always `agent.function` for a function call.
- `conversation_type` (string, required) — The kind of conversation the agent is running. Always `voice`.
- `action` (string, required) — What the request is asking of you. Always `fetch_conversation` for a function call; the end-of-call conversation report sends `post_conversation` instead.
- `meta_data_token` (string, required) — The token that scopes `meta_data`. This is the `meta_data_token` you set on the function, or an MD5 of the function's name when you did not set one.
- `meta_data` (object, required) — Metadata scoped to `meta_data_token`. An empty object when the function has none yet.
- `project_id` (string, optional) — Your project ID, when available.
- `space_id` (string, optional) — Your Space ID, when available.
- `conversation_id` (string, optional) — The conversation ID, when the agent was configured with one.
- `caller_id_name` (string, optional) — The caller's name, when available.
- `caller_id_number` (string, optional) — The caller's number, when available.
- `call_start_date` (long, optional) — When the call was created, as a Unix timestamp in microseconds.
- `call_answer_date` (long, optional) — When the call was answered, as a Unix timestamp in microseconds. `0` when it never was.
- `call_end_date` (long, optional) — When the call ended, as a Unix timestamp in microseconds. `0` while the call is still up.
- `ai_start_date` (long, optional) — When the agent started, as a Unix timestamp in microseconds.
- `ai_end_date` (long, optional) — When the agent stopped, as a Unix timestamp in microseconds. Omitted while it is still running.
- `times` (list of object, optional) — Per-response performance metrics for the session so far. Included once the agent has any.
  - `response` (string, required) — The reply text. Redacted when you enable `redact_prompt`.
  - `response_word_count` (integer, required) — How many words the reply contained.
  - `answer_time` (double, required) — How long the reply took to produce, in seconds.
  - `token_time` (double, required) — How long the model spent generating, in seconds. For an [`ai`](/docs/swml/reference/calling/ai) agent this is the span from the first token to the last; for an [`amazon_bedrock`](/docs/swml/reference/calling/amazon-bedrock) agent it is `answer_time` less a fixed startup estimate, so treat it as approximate there.
  - `tokens` (integer, required) — How many tokens the reply used.
  - `avg_tps` (double, required) — Average tokens per second across the reply.
  - `tps` (double, required) — Tokens per second for this reply.
- `SWMLVars` (object, optional) — SWML variables for the call. Included when the call carries SWML state.
- `SWMLCall` (object, optional) — SWML call state. Included when the call carries SWML state.