SlackBot

my slack bot note

若要使用機器人,請將機器人加到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

https://api.slack.com/interactive-messages

https://api.slack.com/messaging/interactivity

Last updated

Was this helpful?