Mailchimp Mandrill integration
Overview
Section titled “Overview”Mailchimp Transactional (Mandrill) is a transactional email API that can also route inbound mail to a webhook. Orvanta has no dedicated Mailchimp/Mandrill connection type — instead, this integration works entirely through Orvanta’s generic webhook trigger, pointing Mandrill’s inbound webhook at the URL of an Orvanta script or flow.
Webhooks in Orvanta
Section titled “Webhooks in Orvanta”Every script and flow exposes an autogenerated webhook URL from its Details page, which you can call from any external system without writing integration-specific backend code. Requests are authenticated with a token, passed either as an Authorization: Bearer <TOKEN> header or as a token query parameter — both work, so use whichever your sender supports.
Setup steps
Section titled “Setup steps”- Create a script or flow whose input is shaped to receive the parsed payload (e.g. a string parameter named
mandrill_events). - Sign up for Mailchimp Transactional (Mandrill).
- Open Mandrill’s inbound routing settings.
- Add a domain or subdomain you control for inbound mail (e.g.
inbound.example.com). - Add the MX records Mandrill gives you to your DNS provider and wait for them to validate.
- Create a route specifying which recipient addresses should be forwarded.
- From your script/flow’s Details page, copy the webhook URL and generate a token if you don’t already have one.
- Paste the webhook URL — with the token appended, e.g.
https://<your-instance>/api/w/<workspace>/jobs/run/p/<script_path>?token=<TOKEN>— into Mandrill’s “Post to URL” field. - Send a test email through the route to confirm delivery end to end.
Data parsing
Section titled “Data parsing”Mandrill posts the parsed message as a JSON-encoded string in the request body, not as a native JSON payload, so the first step of your flow should decode it before anything else touches the data:
export async function main(payload: string) { return JSON.parse(payload);}Handling directly routed emails
Section titled “Handling directly routed emails”For mail sent straight to one of your route’s addresses, Mandrill’s parsed payload is an array of message objects with sender, subject, and body already broken out. Feed the decoded array from the step above into the next step’s inputs and pull out whichever fields the rest of the flow needs.
Handling forwarded emails
Section titled “Handling forwarded emails”Forwarded mail is different: Mandrill sees a single message where the sender is whoever hit “Forward”, not the original author, and the original headers end up embedded in the body text. A regex-based extraction step recovers them:
import re
def main(raw_email: str): patterns = { 'from': r'From: .+ <(.+)>', 'subject': r'Subject: (.+)', 'date': r'Date: (.+)', 'to': r'To: <(.+)>', 'content': r'\n\n(.*)\n', } matches = { key: re.search(pattern, raw_email, re.DOTALL if key == 'content' else 0) for key, pattern in patterns.items() } result = {key: (m.group(1).strip() if key == 'content' else m.group(1)) if m else None for key, m in matches.items()} return resultHandling both scenarios
Section titled “Handling both scenarios”A single route often receives a mix of direct and forwarded mail, so branch on a cheap signal — such as “Fwd” appearing in the subject — before deciding which parsing path to run:
export async function main(subject: string, marker: string = 'Fwd'): Promise<Output> { const isForwarded = subject.includes(marker); return { isForwarded };}
interface Output { isForwarded: boolean;}Wire the result into a flow branch so forwarded and direct messages hit their respective parsing step.
Advanced use cases
Section titled “Advanced use cases”Once inbound mail lands as structured data in a flow, it composes with anything else Orvanta can do — a few directions worth exploring:
- Route on parsed content (subject, sender domain, keywords) using flow branches
- Push extracted data into a CRM connection (e.g. HubSpot, Salesforce)
- Summarize long threads with an AI step before filing them
- Turn invoice/receipt attachments into structured records automatically
- Fan inbound alerts out to an incident-response flow
- Create tracked tasks in a project-management tool from parsed requests