node.js - 发生 API 错误:在 slack 中打开模式时出现 invalid_arguments
问题描述
我正在尝试在我的 slack 应用程序中打开一个模式
我正在尝试关注模态部分的官方 github 页面,但出现错误
(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 的交互组件 > 操作)
然后,我尝试在处理此交互操作时打开一个模式,但它崩溃了
# 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
解决方案
我打开了一个问题并修复了文档,基本上不可能在视图有效负载中没有提交按钮的情况下查看带有输入的视图
submit: {
type: 'plain_text',
text: 'Submit'
},
推荐阅读
- django - 如何使用 Docker 将 Tailwind css 集成到我的 Django 项目中?
- c++ - 如何加快此目录列表功能?
- c# - 使用实体框架从父路径创建子层次结构
- java - java - 如何使用选择来验证java类中的多个值?
- r - 在 R 中重新分类因子水平
- python - 使用 cython/numpy/通过使用另一个包加速 pandas 数据帧子集
- typescript - 如何在该计算属性方法中读取计算属性的当前值?
- php - ( ErrorTypeError: Failed to fetch ) 当我尝试从 react native 将值插入我的 Mysql 数据库(在线托管)时出错
- javascript - 引导卡上的分页
- pine-script - 是否可以将文本输入一起添加到一个变量中?