Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hrishikeshps/bc69a603ce7e23f2a00e0e8dd4a0c86f to your computer and use it in GitHub Desktop.
Save hrishikeshps/bc69a603ce7e23f2a00e0e8dd4a0c86f to your computer and use it in GitHub Desktop.
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