Google Forms to Slack with Webhooks

BACKSTORY
Occasionally Reclaim Hosting customers will ask for a new hosting account that, for one reason or another, needs to be created manually by a member of RH support. In order to create an account, our system requires a bit of contact information about the user: Name, Email address, Physical Address, and Phone Number. Now we could ask the user to submit this information to us via a support ticket, but in our eyes, it was a little cleaner/more secure to have them fill out a simple Google Form. This has worked well for us, except support members weren’t given any notice when the form was completed. Email notifications are an option, sure, but for a team that has one eye on Slack and one eye on support at any given time, a ping to an inbox somewhere can get lost quickly. So I decided the other day, after watching Tim play around with Slack Webhooks, that I would create one for this simple Google Form. Now when our new customers fill out the form per our request, a notification is sent to our #support channel with the appropriate information. For example:

GETTING STARTED – SLACK PREP

The guides I referenced for this are here & here.

Create a Slack App by going here.

^Give your “App” a name and choose the slack account that you want to add it to. Click Create App.

^Select Incoming Webhooks and then make the toggle in the top right-hand corner is turned ON so Incoming Webhooks is activated. Once activating, the page will refresh- click the button called Add New Webhook to Workspace:

Now choose the channel where you want the content to pull into:

^Click Authorize. You’ll be redirected back to your App Settings, where you should see a new Webhook URL that looks something like the following:

^Keep this page nearby as we will need that Webhook URL soon.

Google Forms

Start by opening the spreadsheet associated with your Google Form. In the menu, click on Tools > Script Editor:

A new window will open. Paste the code found here into the Script Editor.

Next, paste that Webhook URL that you copied from earlier next to:

var slackIncomingWebhookUrl = 'yourWebhookURL.com';

You’ll also want to add the Slack channel that you’re using right beneath it:

var postChannel = "#YourPublicChannel";

^Keep in mind that if the Channel is public, at the # pound sign before it. If the channel is private, leave the # out. Finally, click save.

Initialize and Test

In the Google Form Script Editor, click Initialize in the menu dropdown, and then click the Run:

You’ll be prompted about permission requests. Click Agree.

Lastly, do a test submission on your Google Form. If everything works as planned, you should receive the notification and associated data in your designated Slack channel.

One comment

  1. Mohammed Aswad

    Hey there,
    I am getting this error message:
    “Exception: Unexpected error while getting the method or property forSpreadsheet on object ScriptApp.TriggerBuilder. (line 38, file “Code”)”
    Not sure what to do about it xD
    Thank you

Leave a Reply

Your email address will not be published.

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

Back to Top
css.php