On occasion, we’ve had an issue where a Fiddler Online member hasn’t received a critical email, such as the new order notification email sent by their WooCommerce estore, when a customer places a new order. As you can imagine, that’s a big problem if they don’t receive that email! So I went searching for a solution. I thought for sure there must be a way we could get notifications when something went wrong. Some clients have forms that we built with Gravity Forms, that are also critical.
Our host, Flywheel uses SendGrid to handle all emails sent by sites hosted by them (one of many reasons they’re an incredible host). So all our sites send via SendGrid. We also have our own SendGrid account and run some of our client’s higher priority emails (such as WooCommerce notifications as mentioned) through our account, so we have more control and can see all the details if anything goes wrong. SendGrid tracks everything and makes it easy to see when an email bounces, is dropped or marked as spam. But it doesn’t alert anyone about these things. You’re forced to log in and review everything, including all the successful sends, just looking for the problems. For our small team, it’s just not reasonable for us to check regularly.
So the preferred solution to this problem seemed to be some kind of SendGrid integration that would alert us only when something was wrong. We already use UptimeRobot to alert us when one of our member’s sites goes down. It has a nice integration with Slack (our current team messaging app), so that we get an alert in one of our channels, anytime a site goes down. And we get that notification on our computers and phones. So one of us can always be aware when something goes wrong. That’s how we often fix issues with our member’s sites before anyone notices that there’s even a problem. I figured if we could do the same thing with SendGrid, we’d be good to go.
SendGrid’s Webhook Notifications Don’t Work with Slack
SendGrid has a webhook notification function. So I grabbed a webhook URL from Slack and put it into SendGrid’s Event Notification function. But it wouldn’t work. Slack never posted any messages from the SendGrid webhook. I reached out to both Slack and SendGrid support. It turns out that the SendGrid webhook data isn’t formatted in a way that Slack understands, so it just does nothing.
Zapier to the Rescue
I did a bunch of research and some experimenting, but couldn’t find a way to make it work. Zapier seemed like the logical approach since it’s basically a middle-man to connect various apps and services. But it’s SendGrid integration only had 1 trigger for when a new list is added. I’m not even sure what that is, but it didn’t help me. I reached out to their support. Sam responded, suggesting that I try the Zapier webhook to get the data from SendGrid, then let Zapier reformat it and push it into Slack with their Slack integration.
So I tried it and it worked! Here’s how to do it:
- You’ll need to signup for or log in to Zapier and make a new Zap.
- Select “Webhooks by Zapier” for the trigger, then the “Catch Hook” option.
- Just select “Continue” on the “Pick off a Child Key” step. No need to enter anything.
- Next, it will provide a webhook URL. Copy it.
- Now login to your SendGrid account and go to Settings>Mail Settings.
- Now expand the “Event Notification” section and click “Edit”.
- Paste in the webhook URL you copied in step 4, to the “HTTP POST URL” space.
- Now check which actions you want to be notified on (I did Dropped, Bounced, and Mark as Spam).
- Hit the blue checkmark in the top-right to save and activate.
- Go back to Zapier and select “Okay, I did this” button.
- Now switch back to SendGrid again, and click the “Test Your Integration” button.
- Back in Zapier, it should say the test was successful, click the Continue button.
- Click the “Send Channel Message” option, then Save + Continue button.
- If needed, authorize access to your Slack account.
- Select which Slack channel you want the message posted to.
- Fill the “Message Text” with helpful info such as Email, Status, Reason, Timestamp, etc, by selecting the button on the right, and clicking available options from the drop-down. This is data fields that SendGrid is sending over. Mine is: “Sending error: event email reason | timestamp status sg_message_id category url”. URL is always sendgrid.com but makes it easier to get there quickly.
- If you want to, name the bot, and set an emoji for the icon.
- Finally, click the Create & Continue button. Whew! We’re almost there.
- It should say “Test Successful!” again. Click Finish.
- Now give the Zap a name, and turn it on by clicking the toggle switch. You’re done!
- But it’s a good idea to run a test by going to SendGrid and clicking that “Test Your Integration” button once more.
If you’re a visual learner, here’s a step by step walkthrough from our YouTube Channel: