表单提交后 Slack 对话框不会关闭
Slack dialog doesn't close after form submission
我创建了一个 slack dialog/form 来收集用户的一些信息;表单呈现得很好,我可以毫无问题地填写表单,但在我单击“提交”后它没有关闭,而是给出了一个错误:
We had some trouble connecting. Try again?
我已经发回了 documentation 中的 200 状态 OK。
// menu is the end point of my interactive messages
app.post('/menu', (req, res) => {
console.log('from form submission:', req.body.payload)
res.sendStatus(200);
})
有什么问题吗?我可以看到我的应用程序的控制台日志,仅供参考。
发送 200 OK 是不够的。
它还必须为空或包含格式正确的输入验证错误列表,如 JSON。如果您的回复包含任何其他文本(例如警告消息),则会产生此错误。
正如文档中所说:
When the submission is without exception, your app must respond with
200 OK with an empty body. This will complete the dialog.
我遇到了类似的问题(使用 golang 而不是 JS)。用 200 响应没有帮助,有或没有 body,但是用 204 代码响应并且没有 body 解决了问题。
我创建了一个 slack dialog/form 来收集用户的一些信息;表单呈现得很好,我可以毫无问题地填写表单,但在我单击“提交”后它没有关闭,而是给出了一个错误:
We had some trouble connecting. Try again?
我已经发回了 documentation 中的 200 状态 OK。
// menu is the end point of my interactive messages
app.post('/menu', (req, res) => {
console.log('from form submission:', req.body.payload)
res.sendStatus(200);
})
有什么问题吗?我可以看到我的应用程序的控制台日志,仅供参考。
发送 200 OK 是不够的。
它还必须为空或包含格式正确的输入验证错误列表,如 JSON。如果您的回复包含任何其他文本(例如警告消息),则会产生此错误。
正如文档中所说:
When the submission is without exception, your app must respond with 200 OK with an empty body. This will complete the dialog.
我遇到了类似的问题(使用 golang 而不是 JS)。用 200 响应没有帮助,有或没有 body,但是用 204 代码响应并且没有 body 解决了问题。