The documentation mentions in several places (1, 2, 3) that when a modal is submitted, you get a view_submission payload. But I can't find anything on how you get the payload - it doesn't seem to be an app.event() or app.action() based one. I can't find any example code either.
I've tried tons of things like:
app.event('view_submission', async (everything: any) => {
everything.ack();
console.log("I'm here");
});
But the callback never triggers. I always get a
[ERROR] bolt-app An incoming event was not acknowledged within 3 seconds. Ensure that the ack() argument is called in a listener.
Stranger still, the Events API doesn't contain anything about view_submission either, but the Error confirms it is an event.
So my question is - How are you supposed to respond to a Modal submit using Bolt?
x in one of the [ ])x in each of the [ ])You can use app.view instead of app.event. https://slack.dev/bolt-js/concepts#view_submissions
Thanks @seratch. I've changed my code to look like this:
app.view(/e/g, async (everything: any) => {
everything.ack();
console.log("I'm here");
});
(where the regex pattern should match anything 馃)
But still no luck. I've also tried app.view('view_b' ... like the documentation says, but it doesn't get triggered either. Do you have any other suggestions?
The part is callback_id in your modal view. If you put veiw_b as callback_id in your view, app.view("view_b", async should work for you.
THANK YOU!!! The callback_id was the missing piece. For future readers, it's needed in the first level of the view JSON, i.e. your JSON looks like this:
view: {
"title": ...,
"submit": ...,
"blocks": [...],
"type": "modal",
"callback_id": "a_unique_id",
}
Then you can respond to it with:
app.view('a_unique_id', async (everything) => {
everything.ack();
});
Most helpful comment
The part is
callback_idin your modal view. If you putveiw_bascallback_idin yourview,app.view("view_b", asyncshould work for you.