slack webhook doesnt display blocks

17 views Asked by At

request is accepted by slack, but nothing displays -

import { IncomingWebhook } from '@slack/webhook';

// URL of your Slack Incoming Webhook
const url = process.env.vibe_wh || (() => {throw 'undefined url'})();

// Initialize the webhook with your URL
const webhook = new IncomingWebhook(url);

// The message you want to send using blocks
async function sendMessage() {
  try {
    await webhook.send({
      blocks: [
        {
          "type": "section",
          "text": {
            "type": "mrkdwn",
            "text": "*Hello, World!* Here's a line of _italicized text_ and some `code`."
          }
        },
        {
          "type": "section",
          "text": {
            "type": "mrkdwn",
            "text": "Here's a [link](http://www.example.com)."
          }
        }
      ]
    });
    console.log('Message sent');
  } catch (error) {
    console.error('Error sending message:', error);
  }
}

// Call the function
sendMessage();

the configuration for the webhook is like so:

enter image description here

and the received message just looks like this:

enter image description here

Maybe I need a variable to inject in the message? Can't figure out how to do that.

0

There are 0 answers

Related Questions in SLACK-WEBHOOKS

Related Questions in SLACK-INTEGRATIONS