Sending Slack Messages with Block Kit in Bot Framework V4

Jose Antonio Gonzalez Rodriguez 0 Reputation points
2024-11-27T15:15:23.9366667+00:00

I'm currently using Bot Framework V4 and have successfully connected to a Slack workspace. I can interact with my bot synchronously. However, I'm trying to send an asynchronous message using continueConversationAsync, which works correctly when sending just a string, allowing the message to appear on Slack.

I've referred to this guide: Create a full-fidelity Slack message, but it utilizes the old method with attachments. Slack recommends using Block Kit.

Here’s how the activity being sent to Slack currently looks, but I'm not receiving the message:

const activity = {
          type: 'message',
          channelData: {
            blocks: [
              {
                type: 'header',
                text: {
                  type: 'plain_text',
                  text: slackAttachment.headline,
                  emoji: true,
                },
              },
              {
                type: 'image',
                image_url: slackAttachment.imageUrl,
                alt_text: slackAttachment.headline,
              },
              {
                type: 'section',
                text: {
                  type: 'plain_text',
                  text: slackAttachment.message,
                  emoji: true,
                },
              },
            ],
          },
        } as Partial<Activity>;

await context.sendActivity(activity);
Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
863 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.