Created
July 9, 2023 14:51
-
-
Save hrishikeshps/bc69a603ce7e23f2a00e0e8dd4a0c86f to your computer and use it in GitHub Desktop.
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
const { WebClient } = require('@slack/web-api'); | |
const options = {}; | |
const web = new WebClient(process.env.SLACK_TOKEN, options); | |
const sendSlackMessage = async (message, channel = null) => { | |
return new Promise(async (resolve, reject) => { | |
const channelId = channel || process.env.SLACK_CHANNEL_ID; | |
try { | |
const resp = await web.chat.postMessage({ | |
blocks: message, | |
channel: channelId, | |
}); | |
return resolve(true); | |
} catch (error) { | |
return resolve(true); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment