Module: Slack::Web::Api::Endpoints::Dialog

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/dialog.rb

Instance Method Summary collapse

Instance Method Details

#dialog_open(options = {}) ⇒ Object

Open a dialog with a user by exchanging a trigger_id received from another interaction. See the dialogs documentation to learn how to obtain triggers define form elements.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :dialog (Object)

    The dialog definition. This must be a JSON-encoded string.

  • :trigger_id (Object)

    Exchange a trigger to post to the user.

See Also:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/slack/web/api/endpoints/dialog.rb', line 17

def dialog_open(options = {})
  throw ArgumentError.new('Required arguments :dialog missing') if options[:dialog].nil?
  throw ArgumentError.new('Required arguments :trigger_id missing') if options[:trigger_id].nil?
  # dialog must be passed as an encoded JSON string
  if options.key?(:dialog)
    dialog = options[:dialog]
    dialog = JSON.dump(dialog) unless dialog.is_a?(String)
    options = options.merge(dialog: dialog)
  end
  post('dialog.open', options)
end