56

Rails 与 Slack 整合指南 (2)

 5 years ago
source link: http://blog.xdite.net/posts/2018/06/17/rails-and-slack-integration-guide-2?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

这篇主要来写如何在 Slack 上开发应用。

主要架构

ID0h0y+
  • Slack 主要是透过 OAuth 架构授权,拿到授权后 Token 去做事。
  • 做事分两种,拿使用者的 Token 去做。另一种是 Bot 去做。
  • 所以可以拿权限时,设定也取得自动开一支 Bot 去做事。
  • slack 传回去的 uid 会是 UXXXXXX-TXXXXXX。前者是使用者代号,后者是团队代号

如何设定开 Bot 权限

步骤 1: 打开 Bot

先去开一支 Bot

sqGRJX+

步骤 2: 设定 Scope

  • scope 里面多要一个 bot

如何代替使用者说话

  • scope 用 chat:write:user

比较值得注意的是 bot 能够直接在 #channel 里面发言。但是如果要跟一般使用者 dm

思维比较绕:

im.open

如何互动式对话

EzPPNg+

主要互动式对话有几种:

1. 用 command /slash 这样互动

8em88q+

2. 用 Button 互动

fm27dz+

3. 用对话框互动 Dialogs

sTOsAh+

架构详解

要打开以上功能,请去打开 App 这两样功能 Slash Commands 与 Interative Coponents

3UVz2y+

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK