Skip to main content
Use LithoBlocks with LangChain so your agent can send Slack messages via templates. The agent chooses a template and payload; a tool calls the LithoBlocks API. You get deterministic messages and far fewer tokens because the LLM does not generate Block Kit JSON. The resulting LLM savings help offset LithoBlocks cost, with net cost reduction at higher volumes.

Prerequisites

  • LithoBlocks API key and at least one template
  • Connecting Slack for your LithoBlocks workspace
  • LangChain installed (pip install langchain langchain-openai or 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_id and 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 accepts template_id and payload (mapped to API field data), then POSTs to the LithoBlocks API.
For compile (get blocks without sending), POST to https://api.lithoblocks.com/v1/templates/compile (or your configured base URL plus /v1/templates/compile) with JSON {"template_id": "...", "data": {...}} and return the response to the agent or post blocks 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 with template_id and payload.
The agent will call 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.