Prerequisites
- LithoBlocks API key and at least one template
- Connecting Slack for your LithoBlocks workspace
- n8n with AI nodes (e.g. OpenAI, Anthropic)
- Optional: n8n integration for HTTP and Webhook basics
Why use LithoBlocks with n8n AI
- AI decides content, LithoBlocks builds the message — The AI node outputs
template_idandpayload(e.g. from user input or previous nodes); the HTTP Request node calls LithoBlocks. No need for the AI to output Block Kit JSON. - Lower LLM cost — The AI outputs a small structured object instead of long Slack block structures. LLM savings help offset LithoBlocks cost; at higher volumes, net cost reduction.
- Consistency — Same layout every time; fewer malformed blocks.
Pattern
- AI node — Use an AI node (e.g. OpenAI, Anthropic) with a system or user prompt that asks the AI to return structured data:
template_idandpayload(JSON). Use structured output or JSON mode if available so the output is parseable. - HTTP Request node — Add an HTTP Request node that POSTs to LithoBlocks:
- URL:
https://api.lithoblocks.com/templates/{template_id}/send(or/compile). Set{template_id}from the AI node output (e.g. the expression that reads the AI output field for template_id). - Headers:
Authorization: Bearer YOUR_LITHOBLOCKS_API_KEY,Content-Type: application/json - Body: JSON from the AI node output (e.g. the payload field from the AI node). Map
template_idandpayloadfrom the AI node output into the URL and body.
- URL:
- Optional: Use a Webhook node to receive LithoBlocks webhooks (e.g. button clicks) and feed into another AI node or workflow. See the n8n integration for webhook setup.
Minimal example
- AI node (e.g. OpenAI): Prompt: “Return a JSON object with two keys: template_id (string, the LithoBlocks template ID to use, e.g. ‘tmpl_abc123’) and payload (object matching the template’s placeholders). Example: For an approval message use template_id and payload with keys like user.name, request.title, request.id.”
- Enable JSON/structured output if the node supports it so the response is valid JSON.
- HTTP Request node: Method POST. URL:
https://api.lithoblocks.com/templates/+ (AI output field for template_id) +/send. Body: (AI output field for payload). Headers: Authorization Bearer + your API key, Content-Type application/json. - Success/error: Use the HTTP Request node output (status, body) for success or error handling in the next nodes.
Next steps
AI agents overview
Why templates and agents fit together.
n8n integration
HTTP and Webhook setup in n8n.
API reference
Endpoints, auth, and parameters.
Placeholders
Template data shape and syntax.

