Mailhook and Slack: AI Contract-Clause Extractor Template
Email a contract PDF to a Mailhook, pull the key clauses with AI, and post a clean summary to Slack.
What It Builds
This Spojit template starts with a Mailhook trigger: when a contract PDF is emailed to your unique Mailhook address, an Attachment node fetches the PDF bytes. A Knowledge node in Embed mode loads the document into a Transient collection, then a Knowledge node in Query mode reads back the term, renewal, and liability clauses as structured output. A Connector node on the slack connector posts the summary to a channel so your team sees the highlights without opening the file.
The run is fully push-driven and async: mail arrives, the workflow fires within seconds, the transient collection is created for that one run and cleaned up automatically when it finishes. Each message is deduplicated, so the same contract emailed twice will not post twice.
The Prompt
Paste this into Miraxa, the intelligent layer across your automation, and it builds the workflow and connects the tools for you:
Build a workflow that triggers on a Mailhook. When a contract PDF arrives, use an Attachment node to fetch the first PDF, embed it into a transient Knowledge collection, then query that collection with AI to extract the term length, renewal terms, and liability clauses as structured output. Post a summary of those clauses to the #contracts channel in Slack, including the sender and the email subject.
Connectors Used
- Mailhook trigger - generates a unique address; any contract emailed to it starts a run. No mailbox or OAuth needed.
- Attachment node - fetches the PDF bytes referenced by the Mailhook email (Mailhook workflows only).
- Knowledge node - Embed mode loads the PDF into a Transient collection; Query mode extracts the clauses with a
Response Schemafor structured output. - slack - posts the clause summary to a channel with
send-message.
Customize It
The obvious knobs to change in the prompt: swap #contracts for your own channel, change which clauses get pulled (for example add governing law, payment terms, or auto-renewal notice period), and adjust the Attachment node's Filename pattern to *.pdf if vendors send mixed attachments. To narrow which senders trigger the workflow, add a From allowlist on the Mailhook trigger in the properties panel.
Tips
- Keep the Knowledge Query node's
Response Schematight (one field per clause) so the Slack message stays predictable and easy to read. - Use Transient for the collection so each contract is embedded and discarded per run; you do not need a persistent archive for one-off extraction.
- The Slack post is a single predictable call, so a Connector node in Direct mode on
send-messagekeeps it deterministic and avoids AI cost on that step.
Common Pitfalls
- Attachment fetching is limited to 10 MB per attachment and 25 MB per run by default; very large scanned contracts can exceed this. Compress or split before sending.
- Received emails are retained for 30 days, so re-running an old contract past that window will not find the attachment bytes.
- Scanned (image-only) PDFs need OCR. Set the Knowledge Embed node's
Document Typeto the image/OCR option when contracts are scans rather than text PDFs. - The Slack connection must have access to the target channel, and the channel name in the prompt must match exactly, or
send-messagewill fail.
Related
- Want the step-by-step for a similar mailhook-plus-PDF build? See How to Create Shopify Orders from PO PDFs Emailed to a Mailhook.
- How to Extract Structured Data from PDF Documents with AI.
- Setting Up a Mailhook Trigger.