Response format for a Slack modal submission using Bolt?

67 views Asked by At

I'm using Bolt for developing my slack bot, but I'm having trouble submitting the pop-up modal. My understanding is that this modal will send a POST payload to /slack/form URL (see photo below), so I've used Bolt's customRoutes handler to response with a 200 code and empty body (per Slack's documentation). However, I continue to receive the following error in my hosting platform's logs (Render) when clicking 'Submit':

[ERROR] An unexpected error occurred during a request (POST) made to /slack/form

I've experimented with variations of the response per this post, but none have seemed to work so far with my level of understanding. Has anyone had experience working with Bolt and Modal submissions to offer some guidance?

Slack URL configuration for modals

enter image description here

Submit error

enter image description here

Code

// This is my URL handler
    {
      path: "https://slack-glossary-bot.onrender.com/slack/form",
      method: ["POST"],
      handler: (req, res) => {
        res.writeHead(200);
        res.write();
        res.end();
      },
    },
1

There are 1 answers

0
jrdaz14 On

Correction, I've solved it - per Bolt's documentation (see image below), all request URLS (including interactivity payloads) must end in /slack/events.

enter image description here

enter image description here

Thus, I've changed my code to the following:

    {
      path: "https://slack-glossary-bot.onrender.com/slack/events",
      method: ["POST"],
      handler: (req, res) => {
        res.writeHead(200);
        res.write();
        res.end();
      },
    },