You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Slack API chat_deleteScheduledMessage调用返回invalid_scheduled_message_id问题

Slack定时消息删除失败invalid_scheduled_message_id问题解决

问题根源

你在构造SCHEDULED_MESSAGES时,将post_at参数强制转换为了字符串类型,Slack的chat_scheduleMessage接口要求post_at必须为整数类型的Unix时间戳。传字符串的情况下,接口虽然会临时返回一个格式正确的ID,但后端实际上没有创建合法的定时消息任务,因此调用删除接口时会提示ID无效。

解决方案

  • 修正post_at的参数类型,去掉多余的字符串转换:
# 修改前的代码
# 'post_at': str(int((datetime.now() + timedelta(seconds=20)).timestamp()))
# 修改后的代码
SCHEDULED_MESSAGES = [
    {'text': 'First message', 'post_at': int((datetime.now() + timedelta(seconds=20)).timestamp()), 'channel': 'C02BT07KS8N'},
    {'text': 'Second Message!', 'post_at': int((datetime.now() + timedelta(seconds=30)).timestamp()), 'channel': 'C02BT07KS8N'}
]
  • 确认你的Slack应用令牌拥有chat:write、chat:write:public(公开频道场景)/chat:write:private(私有频道场景)权限,且机器人已经加入你操作的目标频道。
  • 可选验证步骤:创建定时消息后调用list_scheduled_messages方法,打印实际存在的定时消息ID,和你从创建接口拿到的ID做对比,确认任务创建成功。

内容的提问来源于stack exchange,提问作者Ryota Akai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 05:12:03