Created
December 21, 2022 21:23
-
-
Save alexjyong/764a0751fc2c709eeb6e07299a56f5c3 to your computer and use it in GitHub Desktop.
nodeJS slack talk example
This file contains hidden or 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
//this uses node version 16.15.0 | |
import { WebClient } from '@slack/web-api'; | |
// An access token (from your Slack app or custom integration - xoxp, xoxb) | |
const token = "SuperSecretToken"; | |
const web = new WebClient(token); | |
// This argument can be a channel ID, a DM ID, a MPDM ID, or a group ID | |
const conversationId = 'test123'; | |
(async () => { | |
// See: https://api.slack.com/methods/chat.postMessage | |
const res = await web.chat.postMessage({ channel: conversationId, text: 'Check out this link: <https://www.example.com|Example>' }); | |
// `res` contains information about the posted message | |
console.log('Message sent: ', res.ts); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment