是否仍然可以通过发送消息直接响应松弛事件 HTTP POST?
Is it still possible to respond directly to a slack event HTTP POST with a message to send?
我知道当松弛事件发生时,它会以 HTTP POST (https://api.slack.com/events-api). Is there a way to specify a message to send inside of the response body? I was following this (https://medium.com/@vinodhinic/lessons-i-learnt-while-building-slack-apps-3ecc6c929180) 的形式出现,并希望能够做同样的事情。
没有。该文档并未表明您可以,如果可以,文档会明确提及。其他一些用于消息传递的 API(例如 Twilio 的)。
即使可以,Slack 文档中也提供了不应该的充分理由:
Your app should respond to the event request with an HTTP 2xx within three seconds. If it does not, we'll consider the event delivery attempt failed. After a failure, we'll retry three times, backing off exponentially.
Maintain a response success rate of at least 5% of events per 60 minutes to prevent automatic disabling.
Respond to events with a HTTP 200 OK as soon as you can. Avoid actually processing and reacting to events within the same process. Implement a queue to handle inbound events after they are received.
如果您的代码正在工作(即在数据库中查找资料,或进行某种计算,或发出网络请求)准备发送回的响应,您 运行 承担这项工作花费太长时间(阻塞)并且没有及时发回 200 OK 的风险,这意味着您的客户没有按照文档中的规范行事。正如文档所建议的那样,通过将传入的 Webhook 事件放入队列来处理传入的 Webhook 事件,然后根据队列中的内容发出响应。
我知道当松弛事件发生时,它会以 HTTP POST (https://api.slack.com/events-api). Is there a way to specify a message to send inside of the response body? I was following this (https://medium.com/@vinodhinic/lessons-i-learnt-while-building-slack-apps-3ecc6c929180) 的形式出现,并希望能够做同样的事情。
没有。该文档并未表明您可以,如果可以,文档会明确提及。其他一些用于消息传递的 API(例如 Twilio 的)。
即使可以,Slack 文档中也提供了不应该的充分理由:
Your app should respond to the event request with an HTTP 2xx within three seconds. If it does not, we'll consider the event delivery attempt failed. After a failure, we'll retry three times, backing off exponentially.
Maintain a response success rate of at least 5% of events per 60 minutes to prevent automatic disabling.
Respond to events with a HTTP 200 OK as soon as you can. Avoid actually processing and reacting to events within the same process. Implement a queue to handle inbound events after they are received.
如果您的代码正在工作(即在数据库中查找资料,或进行某种计算,或发出网络请求)准备发送回的响应,您 运行 承担这项工作花费太长时间(阻塞)并且没有及时发回 200 OK 的风险,这意味着您的客户没有按照文档中的规范行事。正如文档所建议的那样,通过将传入的 Webhook 事件放入队列来处理传入的 Webhook 事件,然后根据队列中的内容发出响应。