我正在尝试根据用户选择动态填充消息菜单。但是,我不确定如何使用动态选项发送对松弛的响应。是通过chat.postMessage还是chat.update?我都尝试了两次,但没有成功。这是我的代码:
function usr_access (actionName,response_URL) {
var message = {
"text": "Choose the folder which you need access to",
"replace_original": false,
"attachments": [
{
"fallback": "Ooops... something went wrong..",
"callback_id": "DAaccess",
"attachment-type": "default",
"actions": [
{
"name": "fld_list",
"text": "Select",
"type": "select",
"data_source": "external"
}
]
}
]
}
sendMessageToSlackResponseURL(response_URL, message)
}
我收到以下错误消息:
要求 =“ {\” name \“:\” fld_list \“,\” value \“:\” \“,\” callback_id \“:\” DAaccess \“,\” type \“:\” interactive_message \“, \“ team \”:{\“ id \”:\“ xxxxxxxx \”,\“域\”:\“ xxxxxxxxx \”},\“频道\”:{\“ id \”:\“ XXXXXXXX \” ,\“名称\”:\“ directmessage \”},\“用户\”:{\“ id \”:\“ xxxxxxxx \”,\“名称\”:\“ xxxxxxxxxxxxxx \”},\“ action_ts \ “:\” 1545655305.281796 \“,\” message_ts \“:\” 1545654125.002700 \“,\” attachment_id \“:\” 1 \“,\”令牌\“:\” xxxxxxxxxxxxxxxx \“}”请求= interactive_message参考错误:未定义res 在Request.request [作为_callback](SlackApp / events_slack.js:130:12) 在self.callback(SlackApp / node_modules / request / request.js:185:22) 在emitOne上(events.js:115:13) 在Request.emit(events.js:210:7) 在Request.init(SlackApp / node_modules / request / request.js:231:17) 在新请求下(SlackApp / node_modules / request / request.js:127:8) 根据要求(SlackApp / node_modules / request / index.js:53:10) 在sendDynamicList(SlackApp / events_slack.js:128:2) 在app.post(SlackApp / events_slack.js:651:7)
任何帮助或指导将不胜感激。
答案 0 :(得分:0)
问题已解决。我尝试通过res.send()函数以JSON格式发送选项。(认为我们不能以这种方式发送选项)。