Cyril Duchon-Doris
Cyril Duchon-Doris

Reputation: 13949

API error occurred: invalid_arguments when opening a modal in slack

I am trying to open a modal in my slack app

I am trying to follow the official github page on the modal section but I ma getting an error

(node:20175) UnhandledPromiseRejectionWarning: Error: An API error occurred: invalid_arguments
    at Object.platformErrorFromResult (/node_modules/@slack/web-api/src/errors.ts:94:5)
    at WebClient.apiCall (/node_modules/@slack/web-api/src/WebClient.ts:159:13)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

I can successfully receive and start processing interactive actions sent by slack (on my slack app I have registered a Interactive Components > action with appropriate callback id)

I then try to open a modal while processing this interactive action and it crashes

# In my app I build the message adapter 
const slackInteractions = createMessageAdapter(process.env.SLACK_SIGNING_SECRET)
slackInteractions.action({ callbackId: CALLBACK_IDS.MY_CALLBACK_ID }, myHandler)
# which is then mounted as an express middleware, no problem so far

# the handler supposed to open a modal
import { WebClient } from '@slack/web-api';

export default (payload, respond) => {
  try {
    console.info('Slack payload for my callback', payload);
    const trigger_id = payload.trigger_id;
    const web = new WebClient(process.env.SLACK_OAUTH_ACCESS_TOKEN)
    const openModalPayload = {
      trigger_id,
      view: {
        type: 'modal',
        callback_id: 'view_identifier',
        title: {
          type: 'plain_text',
          text: 'Modal title'
        },
        blocks: [
          {
            type: 'input',
            label: {
              type: 'plain_text',
              text: 'Input label'
            },
            element: {
              type: 'plain_text_input',
              action_id: 'value_indentifier'
            }
          }
        ]
      }
    };
    console.log(openModalPayload)
    web.views.open(openModalPayload) # <<- this async call seems to be crashing

Upvotes: 2

Views: 4319

Answers (1)

Cyril Duchon-Doris
Cyril Duchon-Doris

Reputation: 13949

I opened an issue and the documentation was fixed, basically it's not possible to have a view with inputs without a submit button in the view payload

      submit: {
        type: 'plain_text',
        text: 'Submit'
      },

Upvotes: 2

Related Questions