Last active
July 2, 2019 12:33
-
-
Save GrayedFox/a940864be69d3a539fb05c5d528ba5b9 to your computer and use it in GitHub Desktop.
Send personal review request messages via Slackbot channel (sample Gist for Zap integration)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Zap Settings | |
// 1 use GitHub webhooks to send review request notifications to Zapier | |
// 2 apply text filter: action must exactly match "review_requested" | |
// 3 run some JavaScript (i.e. this script) | |
// 4 send a message to a channel (not a direct message), as a bot | |
// 5 use a custom value for the channel ID which takes the output channelId of this script | |
const reviewerName = inputData.reviewer.toLowerCase() | |
const requesterName = inputData.requester.toLowerCase() | |
// object of arrays (slack display names and IDs) with GitHub profile name used as array identifier | |
let slackIds = { | |
freddy: ['Fred', 'U1A2B3C4'], | |
bobfish: ['Bobby Fisher', 'U1A2B3C5'], | |
wakingjeff: ['Jeff', 'U1A2B3C6'], | |
marymagazine: ['Mary M.', 'U1A2B3C7'] | |
} | |
// for hyphenated or special char GitHub profile names use square bracket object syntax | |
slackIds['thomas-jones'] = ['thomas.jones', 'U1A2B3C8'] | |
// the channel and requester ID are the same - this is so the message in Slack appears in the Slack user's Slackbot channel | |
output = { | |
channelId: slackIds[reviewerName][1], | |
requesterId: slackIds[requesterName][1], | |
reviewerId: slackIds[reviewerName][1], | |
requesterName: slackIds[requesterName][0], | |
reviewerName: slackIds[reviewerName][0] | |
} |
Author
GrayedFox
commented
Jul 2, 2019
- Remove superfluous workaround that used shared channel id
- Remove unneeded code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment