Prerequisites
- LithoBlocks API key and at least one template
- Connecting Slack for your LithoBlocks workspace
- LangChain installed (
pip install langchain langchain-openaior equivalent)
Why use LithoBlocks with LangChain
- Deterministic messages — The agent picks a template and data; the tool sends it. No Block Kit in the prompt.
- Lower LLM cost — The agent outputs only
template_idand a small payload; the tool does the HTTP call. LLM savings help offset LithoBlocks cost; at higher volumes, net cost reduction. - Consistency — Same layout every time; fewer malformed blocks.
Implementing the tool
Define a LangChain tool that acceptstemplate_id and payload, then POSTs to the LithoBlocks API.
POST /templates/{template_id}/compile and return the blocks to the agent or post them yourself. See the API reference for request/response shapes.
Using the tool in an agent
Add the tool to your agent’s tools list. The agent can then “send a Slack message” by invoking the tool withtemplate_id and payload.
send_slack_message with the appropriate template_id and payload for your template.
Next steps
AI agents overview
Why templates and agents fit together.
API reference
Endpoints, auth, and parameters.
Placeholders
Template data shape and syntax.

