slack-edge icon indicating copy to clipboard operation
slack-edge copied to clipboard

app.action not responding to block kit sent from app_mention event

Open astev89 opened this issue 1 year ago • 0 comments

Hello! Thank you for creating a great lib!

I have built a simple slack bot and I am using supabase edge functions to handle the requests. I have a simple app_mention event that fires when the bot is mentioned and responds with a block kit that contains a confirm or deny action. Below is a simple, contrived example of my problem:

app.event("app_mention", async ({ context }) => {
    try {
        const blocks: AnyMessageBlock[] = [
            {
                type: "section",
                text: {
                    type: "mrkdwn",
                    text:
                        `:wave: Do you like ice cream?`,
                },
            },
            {
                type: "actions",
                elements: [
                    {
                        type: "button",
                        text: {
                            type: "plain_text",
                            text: "Yep",
                        },
                        action_id: "approve_ice_cream",
                        style: "primary",
                    },
                    {
                        type: "button",
                        text: {
                            type: "plain_text",
                            text: "Nope",
                        },
                        action_id: "reject_ice_cream",
                        style: "danger",
                    },
                ],
            },
        ];

        await context.say({
            blocks: blocks,
            text: "Hi there!",
        });
    } catch (error) {
        console.error("Error handling app_mention event:", error);
    }
});

app.action("approve_ice_cream", async ({ context, payload, ...rest }) => {
    try {
        console.log("APPROVE ACTION PAYLOAD: ", payload);
        console.log("APPROVE ACTION CONTEXT: ", context);
        console.log("APPROVE ACTION REST: ", rest);
        return 'done';
    } catch (error) {
        console.log("APPROVE ACTION FAILURE: ", error);
    }
}, async (all) => {
    console.log("LAST APPROVE CALL: ", all);
});

app.action(reject_ice_cream, async ({ payload, ...rest }) => {
    console.log("DENY ACTION SELECTED PAYLOAD: ", payload);
    return 'done';
});

I have not been able to get the app.action to fire in response to the block kit selection. Any help is appreciated!

astev89 avatar Aug 15 '24 21:08 astev89