在 Slack 中安排消息

Schedule a message in Slack

我需要在提前设定的时间在slack中发送消息。

有没有办法通过 Slack API 或者我需要一个脚本 运行 并检查是否是时候发送消息然后发送?

如果您只想在给定时间向用户发送一条短消息,您可以使用 build-in 提醒。 reminder.add 方法允许您指定日期、时间、消息文本和接收消息的用户。

提醒消息将出现在指定用户的 "Slackbot" 频道中。

这是一个示例:

2019 年 4 月更新:

现在有一个新的 API 方法允许您提交消息以供稍后发送。它叫做 chat.scheduleMessage.

您应该能够创建提醒,向@slackbot 发送消息 消息应该是这样的:

/remind [@someone or #channel] [what] [when]

这里有一些例子:

/remind @username to do something in 24 hours

或:

/remind @username to do something at 16:00

您可以使用这个免费的 Slack 应用程序发送预定消息和自毁消息。 https://timy.website

  1. 正在发送预定消息

/send Happy birthday at 12am

/send Happy birthday in 1h30m

  1. 发送自毁消息

/delete Secret message! at 2pm

/delete Secret message! in 3h

您可以在网站上找到更多详细信息。

您可以使用端点 chat.postMessage 上的官方 slack api 和密钥 post_at 来安排您的 消息official slack documentation https://api.slack.com/messaging/scheduling. You can also use 3rd party applications, which are free most of the time, for example https://thetopchat.com/ 中的更多信息并使用命令安排您的消息,例如:

/delay in 3 hours {your message here}

/schedule tomorrow at 3pm {your message here}

Slack API 现在为此提供了一个专用端点。您将需要 chat:write 范围,文档说:

Schedules a message to be sent to a channel.

我刚刚实施并按预期工作。

您可以在此处查看文档:chat.scheduleMessage