I recently got into making dialogues for my Slack application and was wondering how to take text input from a user with a required formatting style. I have seen apps like EventBot do this when you try to make a new event it opens up a dialogue and a text input line asks you for Date & Time in the specific format MM/DD/YY HH:mm am/pm. If you don't follow this formatting a little red warning appears below the text box when you try to submit the dialogue.
I can't seem to find any documentation as to how to throw this warning when a user doesn't follow your formatting and haven't seen any attribute for getting a date from the user.
Does anyone know what method to call or what attribute I need to include to make this kind of restriction?
-Thank you
This works a bit differently. There is no API to call.
Instead, your apps needs to evaluate the user input (after the dialog is submitted) and can then respond with an error message to Slack if necessary. That error message is then displayed in the Dialog.
Here is the relevant part of the official documentation:
If your app finds any errors with the submission, respond with an application/json payload describing the elements and error messages. The API returns these errors to the user in-app, allowing the user to make corrections and submit again.
And here is the example for a response from the official documentation:
{
"errors": [
{
"name": "email_address",
"error": "Sorry, this email domain is not authorized!"
},
{
"name": "username",
"error": "Uh-oh. This username has been taken!"
}
]
}