1

I am trying to launch a modal for my slack app. The modal has to be launched on click of a button from the base message section. I am using slack block builder ( https://www.blockbuilder.dev/) package to construct the json.

The bolt app has the following:

app.action('watch-skill-video', async ({ ack, action, client, say, respond }) => {

  ack()
  const msg = await watchLayoutBuilder('some value', 'someother value')
  console.log('Message - ' + msg)
  await respond(JSON.parse(msg))

});

I can see the message getting printed as -

{
  "title": {
    "type": "plain_text",
    "text": "Abc"
  },
  "submit": {
    "type": "plain_text",
    "text": "Submit"
  },
  "blocks": [
    {
      "text": {
        "type": "plain_text",
        "text": "Dummy"
      },
      "type": "button"
    }
  ],
  "type": "modal"
}

However along with this, a 404 error is showing up in console ( and off course the popup does not work) !

[ERROR]  bolt-app UnknownError: Request failed with status code 404
    at asCodedError (/Users/rajeshghosh/Projects/pwa-slack/node_modules/@slack/bolt/dist/errors.js:35:12)
    at App.handleError (/Users/rajeshghosh/Projects/pwa-slack/node_modules/@slack/bolt/dist/App.js:608:57)
    at App.processEvent (/Users/rajeshghosh/Projects/pwa-slack/node_modules/@slack/bolt/dist/App.js:593:25)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async SocketModeClient.<anonymous> (/Users/rajeshghosh/Projects/pwa-slack/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js:126:17) {
  code: 'slack_bolt_unknown_error',
  original: Error: Request failed with status code 404
      at createError (/.../node_modules/@slack/bolt/node_modules/axios/lib/core/createError.js:16:15)
      at settle (/.../node_modules/@slack/bolt/node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (/.../node_modules/@slack/bolt/node_modules/axios/lib/adapters/http.js:322:11)
      at IncomingMessage.emit (events.js:412:35)
      at IncomingMessage.emit (domain.js:475:12)
      at endReadableNT (internal/streams/readable.js:1334:12)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    config: {
      transitional: [Object],
      adapter: [Function: httpAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      headers: [Object],
      proxy: false,
      method: 'post',
      url: 'https://hooks.slack.com/actions/TFTS42ALT/3855892288214/7lmakyKKBAvk0paJguVzxoih',
      data: '{"title":{"type":"plain_text","text":"Abc"},"submit":{"type":"plain_text","text":"Submit"},"blocks":[{"text":{"type":"plain_text","text":"Dummy"},"type":"button"}],"type":"modal"}'
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      _header: 'POST /actions/TFTS42ALT/3855892288214/7lmakyKKBAvk0paJguVzxoih HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'User-Agent: axios/0.26.1\r\n' +
        'Content-Length: 179\r\n' +
        'Host: hooks.slack.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/actions/TFTS42ALT/3855892288214/7lmakyKKBAvk0paJguVzxoih',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'hooks.slack.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    response: {
      status: 404,
      statusText: 'Not Found',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    },
    isAxiosError: true,
    toJSON: [Function: toJSON]
  }
}
[ERROR]   An unhandled error occurred while Bolt processed (type: block_actions, error: Error: Request failed with status code 404)

I am using webhooks. Appreciate any help here !

Btw, If I send a simple message instead of modal, it works fine.

Rajesh
  • 419
  • 1
  • 6
  • 20

1 Answers1

2

Well it turns out that the json was not properly constructed for a Modal. When I took the json over to block kit builder it was complaining . I experimented by changing respond to say and it was able to show me the validation errors. Blocks in Modal need to have elements and then the input fields embedded.

So the original issue of receiving 404 from slack is addressed.

However I am experiencing another issue ( modal not rendering the pop-up ), for which I am opening a separate SOF thread.

Rajesh
  • 419
  • 1
  • 6
  • 20
  • Same circumstances, same unhelpful error. Turns out in my case, I had an empty string for *Button* element `value` parameter. Changing it to some non-empty string fixed it. – rightdroid Aug 08 '23 at 12:17