Skip to content

Instantly share code, notes, and snippets.

@deguchi
Created June 25, 2021 00:52
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 deguchi/a33c008621cedc6cb6c198967516523a to your computer and use it in GitHub Desktop.
Save deguchi/a33c008621cedc6cb6c198967516523a to your computer and use it in GitHub Desktop.
const { WebClient } = require('@slack/web-api');
require('dotenv').config();
const token = process.env.SLACK_TOKEN;
console.log('token', token)
const web = new WebClient(token);
const slack = async (text) => {
const result = await web.chat.postMessage({
text: text,
channel: '#bot',
});
// The result contains an identifier for the message, `ts`.
console.log(`Successfully send message ${result.ts}`);
};
module.exports = slack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment