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

# AI agents and LithoBlocks

> Use deterministic templates from AI agents to send Slack messages. Lower LLM cost offsets LithoBlocks pricing; at higher volumes, net cost reduction.

LithoBlocks templates let your AI agent send Slack messages without generating Block Kit JSON. The agent picks a template and fills in the data; LithoBlocks handles the message structure. Use templates so your agent uses far fewer tokens. The resulting LLM savings help offset LithoBlocks credits, with net cost reduction at higher volumes and for richer messages.

## Why use templates with agents

* **Deterministic output** — The agent chooses a template and supplies variables. The LLM does not need to generate Block Kit JSON, so output is predictable and valid.
* **Lower LLM cost** — The agent sends only a template ID and a small payload instead of long block structures. The resulting LLM savings help offset LithoBlocks cost; at higher volumes and for medium/large messages, many customers see net cost reduction.
* **Consistency and safety** — The same layout and structure every time; fewer malformed blocks or prompt drift.
* **Faster iteration** — Change the message in LithoBlocks once; every agent using that template gets the update.

## Common pattern (generic tool)

Your agent decides **what** to do and **what** data to send; the LithoBlocks API handles **how** (the Slack message).

1. **Tool/action inputs:** `template_id`, `data` (template fields; you can keep calling this `payload` in your agent and map it to `data` in the request) and optionally a send destination such as `channel_id`.
2. **One HTTP call:** `POST /v1/templates/compile` or `POST /v1/templates/send` with a JSON body; return success or error to the agent.
3. **Optional:** Use webhooks for two-way flows (e.g. button click in Slack triggers the agent).

## Prerequisites

* LithoBlocks API key (from your [dashboard](https://app.lithoblocks.com) → API Keys)
* At least one template (see [Quickstart](/quickstart))
* [Connecting Slack](/connecting-slack) for your LithoBlocks workspace (required for send)
* Optional: webhook destination if the agent should react to button or modal interactions

## Implementing the tool (generic)

* **Base URL:** `https://api.lithoblocks.com` (staging: `https://staging.api.lithoblocks.com`)
* **Authentication:** `Authorization: Bearer YOUR_LITHOBLOCKS_API_KEY`
* **Paths:** e.g. `POST /v1/templates/compile`, `POST /v1/templates/send` (template id is in the JSON body, not the path). See the [API reference](/api-reference/introduction) for all endpoints and parameters.
* **Body:** JSON with `template_id` and `data` (same shape as [sample data](/guides/templates-sample-data)); send also requires a destination such as `channel_id` where applicable. The agent supplies these fields; your tool forwards them to the API.

Return the API response (or a short success/error message) to the agent so it can decide the next step.

## Platform guides

Same pattern in each framework: define a tool that calls the LithoBlocks API with `template_id` and `data` (often built from an agent-side `payload`), then add that tool to your agent.

<CardGroup cols={2}>
  <Card title="LangChain" icon="robot" href="/guides/langchain-integration">
    Use LithoBlocks from LangChain agents and chains.
  </Card>

  <Card title="LlamaIndex" icon="robot" href="/guides/llamaindex-integration">
    Use LithoBlocks from LlamaIndex agents and tools.
  </Card>

  <Card title="CrewAI" icon="robot" href="/guides/crewai-integration">
    Use LithoBlocks from CrewAI agents and tasks.
  </Card>

  <Card title="n8n AI" icon="robot" href="/guides/n8n-ai-integration">
    Use LithoBlocks from n8n AI nodes (no code).
  </Card>
</CardGroup>

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Build a template and send a message.
  </Card>

  <Card title="API reference" icon="code" href="/api-reference/introduction">
    Endpoints, auth, and parameters.
  </Card>

  <Card title="Placeholders" icon="code" href="/guides/templates-placeholders">
    Template data shape and syntax.
  </Card>

  <Card title="Sample data" icon="database" href="/guides/templates-sample-data">
    Structure payloads for your templates.
  </Card>
</CardGroup>
