- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用“slack-node”npm 包为我的团队构建一个简单的 Slack 应用程序。到目前为止,机器人的初始化工作得很好。在使用自定义斜杠命令后,我得到它来向 channel 发布消息。此消息包含一个交互式按钮,在用户按下该按钮后,消息应该会更新。
来 self 的日志:
// User uses /event slash command
18:48:50 UTC - - Received [POST] to path [/event]
// API response after posting the message
{ ok: true, message_ts: '1506538130.000343' }
// Incoming request after user pressed the button
18:49:32 UTC - - Received [POST] to path [/button_reply]
// Extracted channel id and message ts
C3PEQESP5 1506538130.000343
// respond after using chat.update
{ ok: false, error: 'message_not_found' }
我确保我传递了正确的 channel ID 和消息 ts,我 100% 确定这些参数是正确的,因为您只需要比较响应(对象)。
这是我正在使用的包:https://www.npmjs.com/package/slack-node
这是我使用的代码片段:
module.exports = {
postEphemeral : function(text, body, callback) {
slack.api('chat.postEphemeral', {
attachments:JSON.stringify(text.attachments) ,
channel:body.channel_id,
user:body.user_id
}, function(err, response){
console.log(response);
return callback(null);
});
},
updateMessage : function(text, body, callback) {
console.log(body.channel.id, body.message_ts)
slack.api('chat.update', {
attachments:JSON.stringify(text.attachments) ,
channel:body.channel.id,
ts:body.message_ts
}, function(err, response){
console.log(response);
return callback(null);
});
}
}
我认为 slack-node 包使用了 slack 的 web-api 但不确定。根据 Slack 的说法,“message_not_found”意味着不存在具有请求的时间戳的消息,这是不正确的,消息就在那里。
有没有人以前遇到过相同/相似的问题?感谢您的任何建议。
最佳答案
另一种在用户按下按钮后更新机器人消息的方法(交互式消息)。您可以使用 response_url
,它也包含在来自按钮按下的有效负载中。只需向此 response_url
发出另一个 POST
请求,就像您发布一条简单消息一样。
这适用于 短暂的
消息!
var response_url = body.response_url;
var options = {
url: response_url,
method: 'POST',
body: JSON.stringify(text)
}
request(options,function(err, response, body) {
// Continue doing stuff
});
阅读本文 ( https://api.slack.com/interactive-messages ) 您可能还可以使用一个附加参数(尽管我不知道何时以及如何使用):"replace_original": true
,但还没有尝试过。
关于node.js - Slack API-chat.update : "message_not_found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46455540/
我刚刚创建了一个新的 Slack 应用程序并向其中添加了一个机器人。 现在我有 2 个可用的 token : OAuth 访问 token (xoxp) 机器人用户 OAuth 访问 token (x
我正在构建与 Slack 和客户端的消息传递集成。我需要在用户登录客户端时在相应的对话上显示徽章,以向客户端显示它有多少条未读消息。 我知道 channels.history 方法有 unreads
我有一个 slack POST api 调用,我正在从我的应用程序中调用它:- slack_client.api_call("chat.postMessage", channel=channel, t
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 去年关闭。 Improve this
Slack 默认头像来自哪里?这是他们自己的服务还是第三方服务? 在任何一种情况下,其他人是否有可能使用头像创建服务/系统,例如通过 slack API? 最佳答案 我 asked Slack dir
我正在编写一个脚本,以我的身份发布自动消息。我很难找到我的用户 token 。我必须创建一个应用程序吗? 最佳答案 是的,您必须创建一个应用程序才能生成用户 token 。您可以从此处创建一个应用程序
我正在为一些自动通知创建一个 slackbot,并且我收到了一个请求,让通知占据整个 slack 窗口的宽度,这看起来更干净。我发现 block 似乎占据了一个指定的宽度,并且不会水平延伸超过该点。我
我想创建一个 Slack 命令 /command do-something-with-that-file,同时用户上传文件。 到目前为止,我的命令已收到,但负载中没有文件。这可能吗? 我还在作用域中添
我一直在使用 Slack 操作 API,但不知道如何使用 response_url 在原始消息的线程中发送回复。 chat.postMessage 选项实际上不起作用,因为它需要手动将机器人添加到 c
“Slack”可以将链接展开为视频,但有些服务可以,有些则不能。 Vimeo( https://vimeo.com/ ) 可以在 Slack 中将链接展开为视频。 TED( https://www.t
我想复制一个现有的 Slack 应用程序,只更改一些小的配置。 除了从头开始创建新的 slack 应用程序并重新配置它之外,还有更简单的方法吗? 最佳答案 或者,您可以使用App Manifest 功
On slack - 我可以使用以下文本语法直接从我的两者中标记用户: hello Francois 我想对群组执行同样的操作(不幸的是,我的应用程序只知道群组名称,不知道群组 ID)。是否有这样做
我们使用通信工具 Slack。它在我的左侧边栏中显示了我最近与之进行过直接消息对话的在线和离开用户。我想在列表中看到当前在线的每个人,我们 Slack 服务器上的所有在线用户。在聊天应用程序的侧边栏中
我正在尝试构建一个在首次安装到工作区时执行某些操作的应用程序,例如:Ping 每个团队成员。 我找不到在应用安装时触发的事件类型: https://api.slack.com/events 有什么办法
我有一个发送长消息的机器人。 当它发送多条消息时,用户图标通常会滚出屏幕,因为没有人在机器人的消息之间发送过消息。 这意味着发送消息的时间和发送者不太明显。 有没有办法强制 Slack 为每条消息显示
我不完全确定这是否适合 Stack Overflow... 只是一个简短的问题,希望很多人会觉得有用。 我看到您可以使用主题标签,但它们必须与现有 channel 相对应。我有一个与一个项目相关的 c
例如,我希望在我休息的日子里每天在特定 channel 中显示提醒。就像是: /remind #channel @me will be on PTO 1/1/2016 until 1/5/2016 然
我被一位同事添加到 Slack 工作区。我一定已经接受了移动应用程序上的某些内容,因为我可以访问那里的工作区。不知何故,桌面应用程序从未反射(reflect)过这种变化,也没有表现出知道工作空间的迹象
我是 Slack 的新手,刚刚创建了我的第一个 channel 。在设置 channel 时,我添加了一个目的,但是一旦创建,还有一个添加主题的地方。 channel 的目的和主题有什么区别?它们看起
线程将是 Slack 的一个非常好的特性,只是它们太窄了,我找不到任何方法来配置它们的宽度。 有谁知道如何扩展线程以使其占用所有屏幕空间(在 Slack 内)?放大不会改变窄度。它只会使字体更大。我想
我是一名优秀的程序员,十分优秀!