简体   繁体   中英

Send message to Slack channel when Google Sheet column gets updated (Google Script)

I'm trying to connect my Google Sheet with a Slack Channel. The use case is as follow: I have a Google Sheet which looks like this:

一

There are around 50 so called topics, each of them has internal and external experts listed, also some related files. For now, only the internal experts column of each topic is of interest. Whenever a new person is listed as an internal expert (new cell on the bottom of the column), I want to send out a message to a related slack channel which looks like this:

松弛消息

The message should contain the name or content of the added cell and the name of the Topic he/she was added in as an internal expert (in this case "Topic 1"). The rest is a predefined string. As you can see, I tried to do this with Zapier, and it works. The problem is with Zapier, there seem to be too many limitations when working with several columns. As far as I know, I would have to create a separate Zapier Action for each column, which isn't a really nice solution.

Does anybody can give me a hint how to build this with a Google Script (+ Slack Webhook)? Or if it even makes sense to do so? I'm not an expert in JavaScript + datasets, so I'm struggling a bit on how to start this.

I would suggest to take a look at Triggers for Google App Scripts. You can set a trigger to run every time your Google sheet is edited - see onEdit() . Your trigger can than check if the edit is relevant (eg new cell at the bottom of a specific column) and send a request to Slack using incoming webhooks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM