无法在 slack 斜杠命令请求中获取命令



我在slack上创建了一个斜杠命令。

然而,当我触发它时,我在服务器上收到的帖子请求如下:

{'version': '2.0',
'routeKey': 'POST /server',
'rawPath': '/Work/server',
'rawQueryString': '',
'headers': {'accept': 'application/json,*/*',
'accept-encoding': 'gzip,deflate',
'content-length': '421',
'content-type': 'application/x-www-form-urlencoded',
'host': 'xxx',
'user-agent': 'Slackbot 1.0 (+https://api.slack.com/robots)',
'x-amzn-trace-id': 'xxx',
'x-forwarded-for': 'xxx',
'x-forwarded-port': '443',
'x-forwarded-proto': 'https',
'x-slack-request-timestamp': '1616684124',
'x-slack-signature': 'xxx'},
'requestContext': {'accountId': '255912899710',
'apiId': 'xxx',
'domainName': 'xxx',
'domainPrefix': 'xxx',
'http': {'method': 'POST',
'path': '/Work/Slack_interaction',
'protocol': 'HTTP/1.1',
'sourceIp': '3.89.205.168',
'userAgent': 'Slackbot 1.0 (+https://api.slack.com/robots)'},
'requestId': 'cv6edg75iGYEJaQ=',
'routeKey': 'POST /Slack_interaction',
'stage': 'Work',
'time': '25/Mar/2021:14:55:24 +0000',
'timeEpoch': 1616684124418},
'body': 'xxxtokenxxx',
'isBase64Encoded': True}

根据文档,我没有得到任何commandtext密钥。

有人知道发生了什么吗?

谢谢

这里的问题是交互的细节在有效载荷的主体中,该主体当前按照字段"isBase64Encoded"的建议进行编码:True

解码后,您应该能够获得所需的所有信息。我的实现使用python的base64库,但我相信您可以为您使用的任何语言找到等效的工具。

像slack bolt这样的库也会为您处理这一步骤,以及其他许多步骤。

注意,根据我的测试,所有交互有效载荷都是这样编码的,另一方面,事件有效载荷不是,可以直接解析

最新更新