Post matching Gmail emails to Slack
When a new email matches your Gmail search, its sender, subject and a short preview are posted to a Slack channel with a link to the original, so the team sees it right away.
Install it
Set up this Zap for me, read how here: https://zapier.sh/zapier/awesome-zaps/post-matching-gmail-emails-to-slack/
Paste into Claude, ChatGPT, Cursor or any agent.
- Category
- Personal Productivity · Email management
- Author
- Zapier
- Source
- zapier/awesome-zaps, folder zaps/post-matching-gmail-emails-to-slack
Set it up with the CLI
- Add it. Copies the folder into
zaps/post-matching-gmail-emails-to-slack/. Outside a project, it makes one first.npx zap-pack add awesome-zaps/post-matching-gmail-emails-to-slack - Fill in the values in
config.ts, and in any other file the list marks. Replace each one as its comment and SKILL.md say. - Deploy it. Asks for any value still left, signs you in to Zapier if you aren't, then publishes it to your account.
npx zap-pack deploy post-matching-gmail-emails-to-slack - Check it. Its recent runs, with status and errors.
npx zap-pack logs post-matching-gmail-emails-to-slack
zaps/post-matching-gmail-emails-to-slack/
- README.mdWhat it does, for people
- SKILL.mdHow an agent sets it up: what to ask you, and how to test it
- config.tsIts settings 1 to fill in
- connections/gmail.tsThe
gmailaccount it uses - connections/slack.tsThe
slackaccount it uses - triggers/search.tsWhat starts it:
gmailsearch1 to fill in - workflow.tsThe code; each
ctx.stepis a step in the Zap
Agents: add --yes to any command so it never prompts. When it needs an answer only the user can give, it stops and names the flag that supplies it.
SKILL.md
View MarkdownWhat it does
- Trigger: a new Gmail email matches the search set on the trigger (
gmail,search). The search does all the filtering; the code has no keyword filter. - Slack: one message is posted to the channel. The first line is the sender's name (or address), then the subject in bold, then the first 300 characters of the body, then a link to the original email. Mentions and link previews are switched off.
Ask the user
Each REPLACE_… value is set per person. Resolve channel names to IDs with the user's own connections; don't ask them to paste an ID you can look up.
| Setting | Where | What goes there |
|---|---|---|
REPLACE_GMAIL_SEARCH |
triggers/search.ts |
The Gmail search that picks the emails, using Gmail search operators, e.g. from:billing@example.com in:inbox or subject:(invoice OR receipt) has:attachment in:inbox. Include in:inbox. |
SLACK_CHANNEL |
config.ts |
The channel that gets the posts, looked up from the user's Slack connection. The Slack app must be in that channel. |
Also review the default with them: PREVIEW_LENGTH (300 body characters, in workflow.ts).
Confirm with them as well:
- Which Gmail account is searched, and which sender, subject words or label identify the emails?
- Should the team see the full body or only a preview?
Build it
If you can run shell commands, set it up with zap-pack: run npx zap-pack add awesome-zaps/post-matching-gmail-emails-to-slack, replace each REPLACE_… value as this file says, then run npx zap-pack deploy post-matching-gmail-emails-to-slack, which signs the user in to Zapier when it gets there. Otherwise build with Zapier MCP, as the steps below say. Either way, name the workflow Post matching Gmail emails to Slack (zapier.sh/post-matching-gmail-emails-to-slack): zap-pack takes that name from this file's title, so leave the title as it is, and with Zapier MCP give the workflow that name when you create it. No Zapier MCP tools? Read https://docs.zapier.com/mcp/get-started/quickstart.md and follow the page for the app you are running in to get the user connected, then continue with this build.
- Accounts: bind
slack(used by the workflow's post) to the user's Slack connection for the workspace with the channel, andgmail(used by the trigger) to the Gmail account to search. Both apps need a connection; no other apps are used. - Source: publish
workflow.tsandconfig.ts, with eachREPLACE_…replaced by the user's answer.triggers/search.tsandconnections/are settings, not code: set the workflow's trigger and connection bindings from them, withREPLACE_GMAIL_SEARCHreplaced by the user's search. The trigger file names the app by its slug; for the trigger'sselected_api, callsearch_triggerswith that slug, find the row whosekeyis the trigger'sevent, and use<app_key>@<app_version>from it. - Build guide: load Zapier's build guide with
get_zapier_skill("zapier:build-workflows")and follow it to create, test and publish the workflow. - Fields: inspect each action's fields with the user's connections (and sample the trigger, if it has one) before the first test run, and fix any key in
workflow.tsthat doesn't match.
Test it
Run it once as a draft test before publishing (run_workflow_draft in Zapier MCP). Use a test channel, not the team's real one. The sample is labelled [install-test] and matches the fields the Gmail trigger declares:
{
"subject": "[install-test] Weekly report ready",
"body_plain": "[install-test] The weekly report for test.example.com is ready to review. Open the attached summary for the key numbers.",
"from": {
"name": "[install-test] Reports Bot",
"email": "you@example.com"
},
"message_url": "https://mail.google.com/mail/u/0/#inbox/install-test-1"
}
Check that the run finished and that one message appeared in the test channel with the sender in bold, the subject in bold, the preview and the link. If run-status tools aren't available, check the test channel in Slack directly. Ask the user to delete the test message, since the user deletes test data, not the agent. Then publish, and confirm the trigger is active.
Notes
- The Gmail search is the only filter. A search without
in:inboxalso matches mail the user sent, so those would be posted too. - Gmail's message link opens the original email in the connected account, so only people with access to that inbox can follow it. Anyone who can read the channel sees the sender, subject and preview.
- To post only some of the matches, narrow the search rather than adding code.