How to Auto-Acknowledge Mailhook Inquiries and Log Them to MongoDB
When an inquiry lands in a Spojit mailhook inbox, send an instant acknowledgement reply with the Send Email node and log the inquiry in MongoDB for later follow-up.
What This Integration Does
Customers and partners expect a fast reply when they email you, even outside business hours. This workflow gives every inbound message an immediate, branded acknowledgement so the sender knows you received their inquiry, while quietly recording the full message in a MongoDB collection that your team can search, triage, and follow up on later. You point a shared inbox, a contact-form forwarder, or a vendor notification address at a Spojit mailhook, and Spojit handles the rest with no mailbox connection to maintain.
The workflow is event-driven. A Mailhook trigger generates a unique address; any mail sent to that address starts a run within seconds, with the message available as {{ input }}. Each run sends one acknowledgement back to the sender's reply-to address and inserts exactly one document into MongoDB. There is no polling and no OAuth mailbox. Mailhook deduplicates per message, so a single email never fires the workflow twice, and each run is independent: re-sending the same inquiry creates a new log row only if it is a genuinely new message.
Prerequisites
- A MongoDB connection added in Spojit (Connections → Add connection → MongoDB) with write access to the database and collection you want to log into. A collection named
inquiriesis assumed below; MongoDB creates it on first insert if it does not exist. - A destination for inbound mail you control: a contact-form action, a shared-inbox forwarding rule, or a vendor notification setting you can point at a Spojit-generated address.
- If your acknowledgement reply goes to addresses outside your organisation, add the sender domains to the org allowlist under Settings → General → Email recipients so the Send Email node can deliver.
- A draft of the acknowledgement copy you want senders to receive.
Step 1: Add a Mailhook trigger and generate the address
Create a new workflow and open the Trigger node. Set Trigger Type to Mailhook. Optionally set an Address prefix (1 to 24 characters, default mh) such as support so the address is easy to recognise, then click Generate email address. Spojit produces a unique address of the form support-a1b2c3d4e5f6g7h8@mailhook.spojit.com. Copy it and point your inbox forwarding rule, contact form, or vendor notification setting at it. Every message delivered to that address starts a run and exposes the parsed mail as {{ input }}, including {{ input.from }}, {{ input.subject }}, {{ input.text }}, {{ input.replyTo }}, and {{ input.receivedAt }}.
Step 2: Filter out noise before processing
Still in the Trigger node, narrow what counts as a real inquiry. Use the optional From allowlist to accept mail only from your contact-form address or known partner domains, and the optional Subject regex to require a pattern such as (?i)inquiry|support|question. Filtered messages are dropped before any run starts, so you do not pay for acknowledgements to spam or auto-replies. If you would rather keep all mail but skip obvious bounce and vacation notices, leave the trigger filters open and add a Condition node after it that checks {{ input.subject }} with the text connector's contains tool against terms like out of office and routes those to a dead end.
Step 3: Send the instant acknowledgement reply
Add a Send Email node connected to the trigger. This node uses Spojit's built-in mail service, so no connection is required. Configure it as follows:
- Recipients:
{{ input.replyTo }}so the reply lands wherever the sender expects answers. If a message has no reply-to, fall back to{{ input.from }}. - Subject:
Re: {{ input.subject }}. - Body (plain text, templated), for example:
Hi there,
Thanks for getting in touch. We have received your message and a
member of our team will follow up shortly.
For reference, your inquiry was received at {{ input.receivedAt }}.
Kind regards,
The Support Team
Set Reply-To to your monitored support address, and set If sending fails to Continue anyway so a delivery hiccup never blocks the logging step that follows. Remember that only upstream variables resolve here, and that each send counts toward your monthly email allowance.
Step 4: Shape the document with a Transform node
Add a Transform node after Send Email to assemble a clean record from the raw mail. Build a single object that captures the fields you will want to query and follow up on later:
{
"from": "{{ input.from }}",
"to": "{{ input.to }}",
"subject": "{{ input.subject }}",
"body": "{{ input.text }}",
"messageId": "{{ input.messageId }}",
"receivedAt": "{{ input.receivedAt }}",
"acknowledged": true,
"status": "new"
}
Keeping messageId on the record lets you spot duplicates and trace a logged inquiry back to the exact email. The status field gives your team a simple triage flag to update as they work through follow-ups.
Step 5: Insert the inquiry into MongoDB
Add a Connector node in Direct mode, choose the MongoDB connector, and select the insert-documents tool. Map its inputs:
collection:inquiriesdocuments: an array containing the object from your Transform step, for example[ {{ transform_result }} ]. Thedocumentsinput always takes an array, even for a single record.
Direct mode is deterministic and spends no AI credits, which is exactly what you want for a predictable single-tool write. The tool returns insertedCount in its output, so a value of 1 confirms the inquiry was logged. If you would rather upsert by messageId to make re-runs idempotent, swap the tool for update-documents with a filter of { "messageId": "{{ input.messageId }}" }, an update of { "$set": {{ transform_result }} }, and upsert set to true.
Step 6: Save, enable, and point your mail at the address
Save the workflow and enable it. Confirm the node order reads Trigger → Send Email → Transform → MongoDB connector. Then finalise the forwarding or contact-form rule that delivers mail to your mailhook address. If you ever need to rotate the address (for example after sharing it too widely), open the trigger and use Regenerate address; the old address stops accepting mail instantly, so update your forwarding rule at the same time. If you get stuck wiring the nodes, ask Miraxa, the intelligent layer across your automation, with a specific prompt such as "Add a Send Email node that replies to {{ input.replyTo }} and connect it to a MongoDB connector node that inserts into the inquiries collection".
Tips
- Mailhook fires whether your address is in To, Cc, or Bcc, which makes it ideal for Bcc-style audit logging of inquiries that already flow to a human inbox.
- Add an index on
messageIdandreceivedAtin your MongoDB collection so follow-up queries and duplicate checks stay fast as the collection grows. - Keep the acknowledgement body short and reassuring. Senders only need to know the message arrived; the human follow-up carries the detail.
- Mailhook retains received emails for 30 days, so do not rely on the inbox itself for long-term records: the MongoDB log is your durable copy.
Common Pitfalls
- Sending the acknowledgement to
{{ input.from }}when a reply-to is present can route replies to a no-reply automation address. Prefer{{ input.replyTo }}and fall back to{{ input.from }}only when reply-to is empty. - External recipients that are not on the org allowlist silently fail to receive the reply. Add their domains under Settings → General → Email recipients before going live.
- The
documentsinput expects an array. Passing a bare object causes the insert to fail; always wrap your record in[ ... ]. - Auto-replies and out-of-office messages can ping-pong if you acknowledge them. Use the Subject regex or a Condition node to skip them, and never acknowledge mail whose subject starts with
Re:orAuto:.
Testing
Before pointing production mail at the address, send a single test email from your own mailbox to the generated mailhook address with a recognisable subject. Open the workflow's execution history and confirm the run started within seconds, that the Send Email node reports a successful send, and that the MongoDB connector returned insertedCount of 1. Check your own inbox for the acknowledgement and query the inquiries collection (a find-documents call filtered by messageId works well) to verify the logged document looks right. Once the small-scope test passes, tighten the From allowlist and Subject regex, then switch your real forwarding rule over.