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).- Tool/action inputs:
template_id,payload(and optionally channel/user for send). - One HTTP call: POST to the compile or send endpoint; return success or error to the agent.
- Optional: Use webhooks for two-way flows (e.g. button click in Slack triggers the agent).
Prerequisites
- LithoBlocks API key (from your dashboard → API Keys)
- At least one template (see Quickstart)
- 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 - Authentication:
Authorization: Bearer YOUR_LITHOBLOCKS_API_KEY - Paths: e.g.
POST /templates/{template_id}/compile,POST /templates/{template_id}/send. See the API reference for all endpoints and parameters. - Body: JSON in the shape your template expects (same as sample data). The agent provides this payload; your tool forwards it to the API.
Platform guides
Same pattern in each framework: define a tool that calls the LithoBlocks API withtemplate_id and payload, then add that tool to your agent.
LangChain
Use LithoBlocks from LangChain agents and chains.
LlamaIndex
Use LithoBlocks from LlamaIndex agents and tools.
CrewAI
Use LithoBlocks from CrewAI agents and tasks.
n8n AI
Use LithoBlocks from n8n AI nodes (no code).

