Skip to content

Instantly share code, notes, and snippets.

@GrayedFox
Last active July 2, 2019 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GrayedFox/a940864be69d3a539fb05c5d528ba5b9 to your computer and use it in GitHub Desktop.
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)
// 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]
}
@GrayedFox
Copy link
Author

  • 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