Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle multiple views? #21

Open
hcyildirim opened this issue May 15, 2023 · 4 comments
Open

How to handle multiple views? #21

hcyildirim opened this issue May 15, 2023 · 4 comments
Labels

Comments

@hcyildirim
Copy link

Hi, seems like views_open is not catching up callback_ids, can you help me with that?

# start_new_modal.rb

def self.payload(trigger_id)
    {
      trigger_id: trigger_id,
      view: {
        type: "modal",
        callback_id: "unique-id",
        title: {
          type: "plain_text",
          text: "Start",
          emoji: true
        },
        submit: {
          type: "plain_text",
          text: "Submit",
          emoji: true
        },
        close: {
          type: "plain_text",
          text: "Cancel",
          emoji: true
        },
        blocks: [
          {
            block_id: "conversation",
            type: "input",
            label: {
              type: "plain_text",
              text: "Channel"
            },
            element: {
              action_id: "ml_conversation_input",
              type: "conversations_select",
              response_url_enabled: true,
              placeholder: {
                type: "plain_text",
                text: "Start typing #channel"
              }
            }
          },
        ]
      }
    }
  end
#  actions/task.rb

SlackRubyBotServer::Events.configure do |config|
  config.on :action, "block_actions" do |action|
      payload = StartNewModal.payload(trigger_id)
      slack_client.views_open(payload)
  end
end
# actions/start_new_modal.rb

SlackRubyBotServer::Events.configure do |config|
  config.on :action, 'view_submission', 'unique-id' do |action|
   # nothing comes here
  end
end
@hcyildirim
Copy link
Author

@dblock could you help me please?

@dblock
Copy link
Contributor

dblock commented May 16, 2023

Usually I run this locally with ngrok, first thing to check is whether you get any notification from Slack, then whether you get any config.on :action do ..., etc.

@dblock dblock added the bug? label May 16, 2023
@hcyildirim
Copy link
Author

hcyildirim commented May 16, 2023

Yes, I get that from slack but the action file (actions/start_new_modal.rb) is not triggered at all. Only the default action is triggered.

If I don't add the unique-id everything seems to be fine. Seems like unique-id is corrupting something in the background

@dblock
Copy link
Contributor

dblock commented May 16, 2023

The code that parses the payload is here: https://github.com/slack-ruby/slack-ruby-bot-server-events/blob/master/lib/slack-ruby-bot-server-events/api/endpoints/slack/actions_endpoint.rb. Looks like it only supports block_actions, message_action and shortcut. Care to contribute support for view_submission and view_closed (https://api.slack.com/reference/interaction-payloads/views#view_submission)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants