Slack: チャット投稿 (Incoming Webhook) (Slack: Post Chat (Incoming Webhook))
この工程は、Incoming Webhook を使って Slack にメッセージを投稿します。
Configs:共通設定
  • 工程名
  • メモ
Configs
  • C1: Incoming Webhook の URL *
  • C2: 送信するテキスト#{EL}
  • C3: Attachment の要約 (送信テキストが空の場合に、通知で使用される)#{EL}
  • C4: Attachment の色
  • C5: Attachment のタイトル#{EL}
  • C6: Attachment のタイトルリンク#{EL}
  • C7: Attachment のテキスト#{EL}

Capture

See also

Script (click to open)
  • 下記のスクリプトを記述した XML ファイルをダウンロードできます
    • slack-chat-post-webhook.xml (C) Questetra, Inc. (MIT License)
    • Professional をご利用であればファイルの内容を改変することでオリジナルのアドオンとして活用できます

main();
function main() {
  let jsonReq = {};
if (configs.get("Text") !== "" && configs.get("Text") !== null){
    jsonReq["text"] = configs.get("Text");
  }
  let attachment = {};
  attachAdd(attachment, "Fallback", "fallback");
  attachAdd(attachment, "Color", "color");
  attachAdd(attachment, "Title", "title");
  if (configs.get("Title") !== "" && configs.get("Title") !== null){
    attachAdd(attachment, "TitleLink", "title_link");
  }
  attachAdd(attachment, "AttachText", "text");
  if (attachment !== {}){
    jsonReq["attachments"] = [attachment];
  }
  if (attachment["title"] == null && attachment["text"] == null && jsonReq["text"] == null){
    throw "Message to send isn't set.";
  }
  const url = configs.get("Url");
  
  let response = httpClient.begin()
    .body(JSON.stringify(jsonReq), "application/json; charset=UTF-8")
    .post(url);

  const status = response.getStatusCode();
  const responseTxt = response.getResponseAsString();
  if (status !== 200) {
  engine.log(`${responseTxt}`);
  throw `Failed to send. status: ${status}`;
    throw error;
  }
}
function attachAdd(attachment, config, attachName){
  const value = configs.get(config);
  if (value !== "" && value !== null){
    attachment[attachName] = value;
  }
}
%d人のブロガーが「いいね」をつけました。