SlackBot
my slack bot note
按照此Getting started 建好app 並取得 Tokens
Bot UserToken and token
Bot Token 是給程式代表機器人的權限
AccessToken 是給程式代表User 的權限
若要使用機器人,請將機器人加到channel App-> Add App
import config from "../config;
import "./event";
import { WebClient } from "@slack/web-api";
import { SAMPLE_BLOCKS } from "./uiblock.js";
import { log } from "../utils/logger";
// An access token (from your Slack app or custom integration - xoxp, xoxb)
const web = new WebClient(config.SLACK_AUTH_TOKEN);
const currentTime = new Date().toTimeString();
(async () => {
// Use the `auth.test` method to find information about the installing user
// Use the `chat.postMessage` method to send a message from this app
const { ts } = await web.chat.postMessage({
channel: "#general",
text: "I want to study Sample Blocks",
blocks: SAMPLE_BLOCKS.blocks
});
log("Message posted!", ts);
})();
設計BlockKit 並讓他可以interactive
Last updated
Was this helpful?