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

Update for dialogs #173

Merged
merged 3 commits into from
Sep 30, 2017
Merged

Conversation

alexagranov
Copy link
Contributor

@alexagranov alexagranov commented Sep 29, 2017

We have Dialogs!!!

Note: I removed the auto-generated spec/slack/web/api/endpoints/dialog_spec.rb as even though it passes, it's not technically accurate due to the necessary JSON patch - plus it's tests are already included in the custom dialog_spec.rb.

@dblock dblock merged commit 1aaf5d4 into slack-ruby:master Sep 30, 2017
@dblock
Copy link
Collaborator

dblock commented Sep 30, 2017

👍 😮

@vbanthia-zz
Copy link

@dblock when is it going to be released? Any plan.

@dblock
Copy link
Collaborator

dblock commented Nov 25, 2017

No plan, but I have a bit of time to work on #180 and #181, so maybe today.

@dblock
Copy link
Collaborator

dblock commented Nov 25, 2017

I released 0.11.0.

@vbanthia-zz
Copy link

Thanks :)

@arnoldtonderaimarunda
Copy link

arnoldtonderaimarunda commented Jan 28, 2018

Hi, @alexagranov and @dblock .

Trying to initiate a dialog in a workflow. How do I call the dialog.open method?

Bot.log_dialog(request_data['trigger_id'])

def self.log_dialog(trigger_id)
  dialog = [{
      dialog: [{
      title: "Please provide the following details",
      callback_id: "log:dialog",
      submit_label: "Submit",
      elements: [
          {
              type: "text",
              label: "Starting Time",
              name: "started",
              value: "text",
              hint: "What time did you start work?"

          },
          {
              type: "text",
              label: "Reason",
              name: "reason",
              value: "text",
              hint: "Why were you late?"
          }
      ]
    }]
    }]

  $client.dialog_open(
    trigger_id: trigger_id,
    dialog: dialog.to_json
  )
end


@jmanian
Copy link
Collaborator

jmanian commented Jan 28, 2018 via email

@alexagranov
Copy link
Contributor Author

alexagranov commented Jan 28, 2018

If indeed request_data['trigger_id'] is from an action payload, then I believe your issue may simply be what you're passing for the dialog itself. You probably want:

dialog: dialog.first

after you remove the extra nested dialog: [{ ... hash ;-)

The client already takes care of the .to_json for you btw.

@arnoldtonderaimarunda
Copy link

Thanks @jmanian and @alexagranov for your response, much appreciated.

Yes, the 'request_data['trigger_id'] is coming from an interactive button payload.

I have changed the dialog as per you advice to

def self.log_dialog(trigger_id)
  dialog = [{
      title: "Please provide the following details",
      callback_id: "log:dialog",
      submit_label: "Submit",
      elements: [
          {
              type: "text",
              label: "Starting Time",
              name: "started",
              value: "text",
              hint: "What time did you start work?"

          },
          {
              type: "text",
              label: "Reason",
              name: "reason",
              value: "text",
              hint: "Why were you late?"
          }
      ]
    }]

  $client.dialog_open(
    trigger_id: trigger_id,
    dialog: dialog.first
  )
end

However, The error I am obtaining is
2018-01-29 12:04:08 - NoMethodError - undefined method dialog_open for #<Slack::Web::Client:0x00000002ecb510>:

@arnoldtonderaimarunda
Copy link

arnoldtonderaimarunda commented Jan 29, 2018

Gentlemen, the undefined method issue was due to using a lower version of 'Slack-Ruby_Client'. Was on '0.9.1' instead of at least '0.11.0'. I have upgraded to '0.11.1'.

Everything working great. Thanks very much. However, I seemed to encounter dialog validation errors when the title was too long.

@alexagranov
Copy link
Contributor Author

👍 Good to know there's a length limit!

@vbanthia-zz
Copy link

Yes, there is indeed a length limit and it is very difficult to troubleshoot those issues because current ruby-client will only raise error saying validation_errors. It would be good to add response_metadata into error description.

https://api.slack.com/methods/dialog.open

@dblock
Copy link
Collaborator

dblock commented Jan 29, 2018

@vbanthia This would be useful, PR?

@vbanthia-zz
Copy link

@dblock #201

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

Successfully merging this pull request may close these issues.

5 participants