An AppsScript project to forward emails with specific word in the subject line or body from Gmail to a Slack channel
- Gmail address needs to be added to target Slack
- You need to set up an incoming webhook on Slack for that Gmail address & the target Slack channel
- In the Gmail account which should forward the emails, set up a label for conversations that should be forwarded, ie "Project"
- Create a filter rule to apply that label automatically to incoming messages (ie if there's the word "project" in the subject line or message body)
- Connect the application "Export Emails to Google Sheets" by CloudHQ to that Gmail account, use the following settings
- In the spreadsheet you set up during the last step, add Apps Script configured with your settings (see comments in the script)
- Set up a trigger, easiest is time-based, ie hourly/daily etc
The script does 4 things:
- Get data that hasn't been forwarded yet from Spreadsheet
- Transform data into Slack format (blocks)
- Send alert to Slack
- Update data rows: mark as forwarded to avoid sending duplicates