如何使用 Circuit Bot 通过 Rest API Message 在 Circuit Conversation 中发布消息
How to use a Circuit Bot to publish a message in Circuit Conversation via Rest API Message
我正在尝试通过 Circuit Bot 通过 Rest API 调用在电路对话中发送 post 消息。请帮忙。
分两步完成:
- 使用身份验证端点为您的机器人获取令牌
- 使用消息端点(和步骤 1 中的令牌)发布消息
假设您已经拥有:
- 一个机器人(客户端 ID,客户端密码)
- 对话 ID(机器人必须是它的参与者)
第 1 步:获取令牌
curl -X POST
https://<circuitBaseUrl>/oauth/token \
-H 'Authorization: Basic <base64-encode(<clientId>:<clientSecret>)>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&scope=WRITE_CONVERSATIONS'
从响应中获取 access_token
第 2 步:使用 REST API 到 post
curl -X POST \
https://<circuitBaseUrl>/rest/v2/conversations/<conversationId>/messages \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: beta.circuit.com' \
-d content=hello%20from%20postman
Welcome to the Circuit Developer Community ;-)
您有两个选择:
使用传入的 webhook。这非常简单,不需要 OAuth,因为 webhook url 包含令牌和特定对话。拥有此 url 的任何人都可以 post 加入对话。有两种选择,post 作为你自己,或 post 作为机器人。如果你想 post 作为机器人,那么你首先需要使用 "Manage Application > Custom Apps" 页面创建一个 webhook 机器人。有关更多信息,请参阅 https://www.circuit.com/unifyportalfaqdetail?articleId=164448 和这些常见问题解答页面上的其他 webhook 文章。
这是 url 传入 webhook 上 post 消息的示例 url。
curl https://circuitsandbox.net/rest/webhooks/incoming/9999999-0b95-4088-b272-5bef80f8e68e -H "Content-Type: application/json" -d '{"text":"hello world"}'
通过 "Manage Application > Custom Apps" 创建一个实际的 OAuth 2.0 机器人并使用常规 REST API(https://circuitsandbox.net/rest/v2/swagger/ui/index.html). There are several REST examples on github. See https://github.com/circuit/circuit-REST-bot 用于简单的 REST 机器人示例。
我正在尝试通过 Circuit Bot 通过 Rest API 调用在电路对话中发送 post 消息。请帮忙。
分两步完成:
- 使用身份验证端点为您的机器人获取令牌
- 使用消息端点(和步骤 1 中的令牌)发布消息
假设您已经拥有:
- 一个机器人(客户端 ID,客户端密码)
- 对话 ID(机器人必须是它的参与者)
第 1 步:获取令牌
curl -X POST
https://<circuitBaseUrl>/oauth/token \
-H 'Authorization: Basic <base64-encode(<clientId>:<clientSecret>)>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&scope=WRITE_CONVERSATIONS'
从响应中获取 access_token
第 2 步:使用 REST API 到 post
curl -X POST \
https://<circuitBaseUrl>/rest/v2/conversations/<conversationId>/messages \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: beta.circuit.com' \
-d content=hello%20from%20postman
Welcome to the Circuit Developer Community ;-)
您有两个选择:
使用传入的 webhook。这非常简单,不需要 OAuth,因为 webhook url 包含令牌和特定对话。拥有此 url 的任何人都可以 post 加入对话。有两种选择,post 作为你自己,或 post 作为机器人。如果你想 post 作为机器人,那么你首先需要使用 "Manage Application > Custom Apps" 页面创建一个 webhook 机器人。有关更多信息,请参阅 https://www.circuit.com/unifyportalfaqdetail?articleId=164448 和这些常见问题解答页面上的其他 webhook 文章。
这是 url 传入 webhook 上 post 消息的示例 url。
curl https://circuitsandbox.net/rest/webhooks/incoming/9999999-0b95-4088-b272-5bef80f8e68e -H "Content-Type: application/json" -d '{"text":"hello world"}'
通过 "Manage Application > Custom Apps" 创建一个实际的 OAuth 2.0 机器人并使用常规 REST API(https://circuitsandbox.net/rest/v2/swagger/ui/index.html). There are several REST examples on github. See https://github.com/circuit/circuit-REST-bot 用于简单的 REST 机器人示例。