in ,

How to Get SendGrid Alerts in Slack When WordPress Messages Bounce

The Problem

On occasion, we’ve had an issue where a WordXpress member hasn’t received a critical email, such as the new order notification email sent by their WooCommerce estore. As you can imagine, that’s a big problem if they don’t receive that email! Some clients have forms that we built with Gravity Forms that are also critical. So I went searching for a solution. I thought for sure there must be a way we could get notifications when something went wrong.

Send WordPress Transactional Email with SendGrid

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.

Get Notifications in Slack

Slack notificationSo 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 Webhooks 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.

Screen shot 2017 04 19 at 4.11.05 pm

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:

  1. You’ll need to signup for or log in to Zapier and make a new Zap.
  2. Select “Webhooks by Zapier” for the trigger, then the “Catch Hook” option.
  3. Just select “Continue” on the “Pick off a Child Key” step. No need to enter anything.
  4. Next, it will provide a webhook URL. Copy it.
  5. Now login to your SendGrid account and go to Settings>Mail Settings.
  6. Now expand the “Event Notification” section and click “Edit”.
  7. Paste in the webhook URL you copied in step 4, to the “HTTP POST URL” space.
  8. Now check which actions you want to be notified on (I did Dropped, Bounced, and Mark as Spam).
  9. Hit the blue checkmark in the top-right to save and activate.
  10. Go back to Zapier and select “Okay, I did this” button.
  11. Now switch back to SendGrid again, and click the “Test Your Integration” button.
  12. Back in Zapier, it should say the test was successful, click the Continue button.
  13. Click the “Send Channel Message” option, then Save + Continue button.
  14. If needed, authorize access to your Slack account.
  15. Select which Slack channel you want the message posted to.
  16. 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.
  17. If you want to, name the bot, and set an emoji for the icon.
  18. Finally, click the Create & Continue button. Whew! We’re almost there.
  19. It should say “Test Successful!” again. Click Finish.
  20. Now give the Zap a name, and turn it on by clicking the toggle switch. You’re done!
  21. But it’s a good idea to run a test by going to SendGrid and clicking that “Test Your Integration” button once more.

Video Walkthrough

If you’re a visual learner, here’s a step by step walkthrough from our YouTube Channel:

Too Technical or Don’t Have Time?

If this is too technical for you, sign up for one of our WordXpress WordPress support plans and we’ll connect your website to our SendGrid account and monitor any issues for you using the solution above. We monitor a bunch of other stuff too, so you can relax, knowing your website is working great!

Tevya

Hi, I’m Tevya! I wrote this. I am the owner of WordXpress and also created Starfish Plugins. I love helping small businesses and WordPress professionals. My wife Jill, helps with the business and is the amazing CEO of our family (3.5 kids). When I’m not working, I like to play basketball, go boating, shoot targets, swim, serve in my church, play Ultimate, and have outdoor adventures as a family.

Full Stack WordPress Designer and DeveloperDinar M Islam

Full Stack WordPress Designer and Developer

M: 088 019 24239141

E: hello@dinarmislam.com

 Dinar M Islam on Freelancer.comHire me on Freelancer.com

What do you think?

0 points
Upvote Downvote

Written by Dinar M Islam

More than 6+ years experience in web development specially on wordpress design and development. Making website that will sell your target. Writing and sharing knowledge about wordpress development in leisure time.

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Loading…

0

Comments

0 comments

A Message from Kurt to All Our Fiddler Online Clients

A Message from Kurt to All Our Fiddler Online Clients

How to Style Give WP's Email Access Token Fields and Buttons

How to Style Give WP’s Email Access Token Fields and Buttons