How to Mention Someone in a Slack Message from Google Forms
Learn how to send messages to Slack from Google Form and Google Sheet. You can also tag or mention a Slack user in the chat message.
This video tutorial explains how you can automatically send Slack messages from Google Forms with the help of Document Studio.
For this example, we have an event registration form created with Google Forms. When a participant completes the form and clicks the submit button, a message is instantly posted in the company’s Slack channel with details of the attendee like their name and email address.
The Google Form has a “Preferred Location” question as well and based on this answer, a specific member of the team will be tagged or mentioned in the Slack message. For instance, if the attended selects New York as the location in the form, the internal Slack message will tag @Angus since they takes care of New York registrations.
Send Slack Messages on Google Form Submit
Go to your Google Form and launch Document Studio. Create a new workflow and add a Slack
task.
Connect your Google Account to your Slack account and you’ll be presented with a list of #channels available in the Slack workspace that you have linked with your account.
Select the relevant Slack channel where you wish to post messages and specify the message template that will be sent to Slack on new form submissions.
The template message includes variables like {{ Attendee Name }}
which will be replaced with the values from the form submission. It also includes a scriptlet to add conditional content in the Slack message.
The Scriptlet looks at the Location
entered in the Google Form and, based on the answer, a specific user gets tagged in the Slack message. You can learn more about the syntax of Scriptlets here.
🎉 {{Attendee Name}} would attend the event from {{Location}}
{% assign answer = "{{ Location }}" %}
{% if answer == "New York" %}
<@U08N2HAQTF9>
{% elsif answer == "Boston" %}
<@U05N6HAQZM1>
{% else %}
<@U09PX8AQLJ1>
{% endif %}
How to @Mention a Slack User
Slack assigns a unique ID to each account and we put this ID in the Slack message to mention / tag that user in the message.
To obtain the User ID of a Slack account, follow these steps:
- Open
slack.com
, navigate to your Slack channel and find any @mention of the user you’re interested in. - Right-click the @mention, and from the contextual menu, select “Copy link.”
The user link you’ve copied will have the following format:
labnol.slack.com/team/U05N6HAQZM1
In this link, the portion starting with U… represents the User ID of the Slack user.
If you want to @mention this user in your Slack message, enclose the User ID inside angle brackets and prefix it with the @ symbol, like this:
How are you <@UABC123> 🎉
Amit Agarwal
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory