发生API错误:在松弛状态下打开模式时,invalid_arguments

时间:2019-09-26 22:50:51

标签: node.js slack-api node-slack-sdk

我正在尝试在我的松弛应用程序中打开模式

我正在尝试遵循官方的github page on the modal部分,但可能会遇到错误

(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)

我可以成功接收并开始处理slack发送的交互操作(在我的slack应用中,我已经注册了具有相应回调ID的Interactive Components>操作)

然后我在处理此交互操作时尝试打开一个模式,它崩溃了

# 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

1 个答案:

答案 0 :(得分:1)

我打开了一个issue,并且文档已修复,基本上,在视图有效负载中没有提交按钮的情况下,几乎不可能有带有输入的视图

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