0
Send error to slack channel Failure
One script reply has been approved by the moderators Verified
Created by rubenfiszel 676 days ago Viewed 46171 times
0
Submitted by rubenfiszel Deno
Verified 676 days ago
1
import { WebClient } from "https://deno.land/x/slack_web_api@1.0.0/mod.ts";
2

3
type Slack = {
4
  token: string;
5
};
6
export async function main(
7
  message: string,
8
  name: String,
9
  channel: string,
10
  slack: Slack,
11
) {
12
  const web = new WebClient(slack.token);
13
  const flow_id = Deno.env.get("WM_FLOW_JOB_ID");
14
  const text = (message = `Flow [${flow_id}](${Deno.env.get(
15
    "WM_BASE_URL",
16
  )}/run/${flow_id}?workspace=${Deno.env.get(
17
    "WM_WORKSPACE",
18
  )}) had an error:\n${name}: ${message}`);
19
  await web.chat.postMessage({
20
    channel,
21
    text,
22
  });
23
  return { message, flow_id };
24
}
25