Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack dialog doesn't close after form submission

I created a slack dialog/form to collect some information from users; The form renders just fine and I can fill out the form without a problem but it doesn't close after I click Submit, instead it gives an error:

We had some trouble connecting. Try again?

I've already sent back a 200 status OK as in the documentation.

// 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);
})

What could be wrong? I can see the console log for my app, fyi.

like image 750
Psidom Avatar asked Feb 09 '18 22:02

Psidom


People also ask

How do I close a modal in slack API?

Closing views An app has the ability to close views within a modal. This can happen only in response to the user clicking a submit button in the modal, sending the view_submission payload. After receiving this payload, your app has 3 seconds to respond and close the submitted view, or close all views.

What are slack bots?

What are bots? A bot is a type of Slack App designed to interact with users via conversation. A bot is the same as a regular app: it can access the same range of APIs and do all of the magical things that a Slack App can do.


1 Answers

Sending a 200 OK is not enough.

It also has to be empty OR contain a list of input validation errors in the correct format as JSON. If your response contains any other text (e.g. a warning message) it will create this error.

As it says in the documentation:

When the submission is without exception, your app must respond with 200 OK with an empty body. This will complete the dialog.

like image 67
Erik Kalkoken Avatar answered Sep 26 '22 14:09

Erik Kalkoken