twilio - 将变量从 slack webhook 传递到 Autopilot
问题描述
我想知道是否可以将来自 Slack 的传入帖子请求中的用户名与 Autopilot 一起使用。
我已尝试检查文档,但找不到任何有关处理 Autopilot 传入请求的参考。也许它不受支持,但有人知道它是否可能吗?
解决方案
我最终能够使用来自 Autopilot 的响应数据,并发现我能够从 json 响应中获取用户标识符,如下所示:
user_name = request.form['UserIdentifier']
这允许我通过传入的 webhooks 应用程序在 slack 中发送直接消息,因为使用上述用户名作为通道键的值,如下所示。
payload={'text':"Ok, I'm working on it. I'll let you know when your request is ready.", "channel":user_name}
webhook_url= 'https://hooks.slack.com/services/<slack id>/<slack id>'
response = requests.post(
webhook_url, data=json.dumps(payload),
headers={'Content-Type': 'application/json'})
if response.status_code != 200:
raise ValueError(
'Request to slack returned an error %s, the response is:\n%s'
% (response.status_code, response.text)
)
推荐阅读
- ios - 不间断的iOS语音识别?
- c# - 为什么“abcd”.StartsWith("ــــــــــــ") 返回真?
- firebase - React Native Firebase Phone Auth - phoneAuthSnapshot 的 verifyId 和 code 具有 NULL 值
- javascript - Firefox 浏览器中的日期更改问题
- c# - 如何使用 SOAP API 对 Salesforce 营销云执行 SQL 查询?
- java - Add values from basic array to Set
- kubernetes - 在 Kubernetes 中为 Statefulset 应用 HPA?
- rust - 解析整数或使用 unwrap_or 提供默认值,但在使用默认值时打印错误消息
- c# - 如何在检查复选框的状态更改时触发按钮事件
- flutter - 您的应用程序无法编译,因为它的依赖项无法在颤振中建立