Send AdWords alerts directly to Slack with this AdWords script library

google-adwords-slack

Ugh, email. For years, we’ve tried to get rid of it, but it remains the communication tool of choice with more than 205 billion emails a day sent in 2015. It’s not going away, but at least at the companies where I’ve worked, many of the alerting and monitoring emails have been replaced with Slack notifications.

One of the best parts of Slack is the huge number of apps and integrations that allow you to run commands and push notifications into the system. Alerts that would normally clutter your inbox are now pushed to the team so that everyone can see and respond if needed.

AdWords alerting pushed to Slack

One of the useful features of AdWords scripts is alerting you when something is going wrong in your account. For example, longtime AdWords script advocate Frederick Vallaeys recently wrote a script to notify you if your account has stopped receiving impressions — extremely handy, until the person it is sending an email to is out on vacation.

In this post, I’m going to share a library you can add to your script that will enable you to send Slack alerts to your #marketing channel when things are going wrong in your account. Here is the full code; below, I’ll explain how to set it up.

Configuring Slack for incoming webhooks

To use this library, you first need to enable the incoming webhooks integration in your Slack installation. You might need to talk to your Slack admin to enable this.

Once you have the custom webhook enabled, you should find a URL that looks something like this: http://ift.tt/1LeDbDT;

That’s the webhookUrl that you pass into the SlackAPI library when you create a new instance of it.

This is an incredibly simple library that only has one function: sendMessage. Here’s how you can send simple messages to Slack.

You can find more information on formatting messages on the Slack api documentation page.

Attachments

If you want to make your messages look a little better, you’ll probably want to play around with attachments. Here’s what it might look like in your Slack channel and the code to generate it.

Sample Slack Alert

This is just one example. You can (and probably should) add links to any supporting reports and to the AdWords login, as well.

Conclusion

By adding this library to the end of any script, you can instantly enable notifications from AdWords Scripts to any Slack channel. You can use this anywhere you are using the MailApp.sendEmail function in your scripting.

I hope you find this as useful as I do as a way to remove some of those alerts from your inbox. Happy Slacking!

AdWords Scripts Workshops from Google

One final note: The AdWords Scripts Team at Google has added a few more workshops to help you get started with scripts. They are free and, in my opinion, extremely helpful. If you want to improve the scripts you use now or develop some on your own, I highly recommend this training.

The post Send AdWords alerts directly to Slack with this AdWords script library appeared first on Search Engine Land.