Edits history of script submission #22532 for ' Send error to slack channel (slack)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { WebClient } from "@slack/web-api";
    
    type Slack = {
      token: string;
    };
    export async function main(
      message: string,
      name: string,
      channel: string,
      slack: Slack,
    ) {
      const web = new WebClient(slack.token);
      const flow_id = Bun.env.WM_FLOW_JOB_ID;
      const text = (message = `Flow [${flow_id}](${Bun.env
        .WM_BASE_URL}/run/${flow_id}?workspace=${Bun.env
        .WM_WORKSPACE}) had an error:\n${name}: ${message}`);
      await web.chat.postMessage({
        channel,
        text,
      });
      return { message, flow_id };
    }
    

    Submitted by hugo989 6 days ago