question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Listen to a modal view submission in slack/bolt?

See original GitHub issue

Description

Hello, currently i am using “@slack/bolt”: “^2.0.1” package to create a bot for Slack. I want to add some interaction to user, when he types a command a dialog modal will open and he has to fill some data and submit those data.

Here is the command invocation and sending of a view modal…

app.command('/test-zenbot', async ({ ack, body, context }) => {
  // Acknowledge the command request
  await ack();

  try {
    const result = await app.client.views.open({
      token: context.botToken,
      // Pass a valid trigger_id within 3 seconds of receiving it
      trigger_id: body.trigger_id,
      // View payload
      view: createTicketModal()  
    });
    console.log(result);
  }
  catch (error) {
    console.error(error);
  }
});

Now, my question is, how should i listen to form/view/modal data submission?

All the time i am getting this error on modal the moment i click the submit:

We had some trouble connecting. Try again?

I am trying to listen to modal/form submission through the bolt view method

app.view(‘bot_create_ticket’, async ({ ack, body, view, context }) => {

await ack(); });

But, to no avail. Any help on this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
joematunecommented, Oct 18, 2021

For me, my modal didn’t have a callback_id property which was needed for app.view(/my_callback_id/, ... to listen for the submission event. Alternatively, you can listen with the event type, i.e. app.view({ type: "view_submission" }, ...

2reactions
erkand-imericommented, May 5, 2020

I found out that in order for app.view to work i have to set the request URL in Interactivity and Shortcuts in Slack App Management UI to: /slack/events instead of /slack/actions as was previously.

Now, it works. The only thing i wonder is after the user submits the view/modal/form how can i check in app.view() which channel id he sent the view/modal/form. In app.messages() we have the say() function where you write back to the channel, but in app.view() i cannot find a way to get the channel informations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to listen for Modal submission on Slack Bolt?
Then, to listen to submissions on the above Modal, use this: app.view('YOUR_CALLBACK_ID', optionalMiddleWareFunction, async ({ payload }) ...
Read more >
Using modals in Slack apps
The app handles the view submission and responds by clearing the view stack. ... Upon submission of a modal view, an interaction payload...
Read more >
Bolt for Python - Slack Platform Developer Tools
Actions, commands, shortcuts, options requests, and view submissions must always be ... The open_modal shortcut listens to a shortcut with the callback_id ...
Read more >
Triggering Modals | Tasks App | Slack Platform - YouTube
Modals provide focused spaces ideal for requesting and collecting data from users, or temporarily displaying dynamic and interactive ...
Read more >
slack-bolt - PyPI
The Bolt Framework for Python. ... pip install slack-bolt ... Listen for view_submission modal events app.view(callback_id)(fn) # Listen for options ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found