通过 Zapier 计算匹配短语消息 Slackbot

Count matching phrase message Slackbot via Zapier

我正在尝试创建一个响应斜杠命令的 Slackbot,计算特定短语在特定日期之后在特定频道中出现的次数。我已经成功地设置了一个 Zapier 管道来捕获请求、格式化搜索并 returns 结果。大致如下:

in:#[channel] “[searchText]” after:[dd/mm/yyyy] 

Zapier 的 Slack 搜索集成似乎只能 return 一条消息。有没有办法通过 Zapier 或其他方法获取我正在寻找的消息数。

我可以通过 python 脚本来做到这一点,但我想以 Slackbot 的形式传递响应。 Zapier 的代码应用状态:

Unfortunately you cannot require external libraries or install libraries commonly referred to as "pip modules".

这使我无法在 Zapier 中编写 python 片段,因为代码需要使用 slackclient.

如果您想开发自己的逻辑:以下是如何计算某个短语在频道内出现的次数:

  1. 通过调用API方法conversations.history.

  2. 获取特定时间段内频道内的所有消息
  3. 浏览所有邮件并计算包含短语

  4. 的邮件

来自 Zapier 平台团队的大卫。

slackclient 只是他们(功能非常齐全,IMO)API 的包装。要使用它的功能,您有几个选择:

  1. 如果您习惯编写 javascript,请创建一个 custom private app with a "search message and count" action. You can use the slack JS sdk (since the CLI can use npm modules) or use the included z.request to write API code. Then you can return whatever data you'd like. If you go this route, you can get started with the template
  2. 如果你想坚持使用 Python,你可以使用请求模块 (docs here) 使上述 Slack API 调用你自己。

希望这能为您指明正确的方向!