Module: Slack::Web::Api::Endpoints::Conversations

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

Instance Method Summary collapse

Instance Method Details

#conversations_acceptSharedInvite(options = {}) ⇒ Object

Accepts an invitation to a Slack Connect channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel_name (string)

    Name of the channel. If the channel does not exist already in your workspace, this name is the one that the channel will take.

  • :channel_id (Object)

    ID of the channel that you’d like to accept. Must provide either invite_id or channel_id.

  • :free_trial_accepted (boolean)

    Whether you’d like to use your workspace’s free trial to begin using Slack Connect.

  • :invite_id (Object)

    ID of the invite that you’d like to accept. Must provide either invite_id or channel_id. See the shared_channel_invite_received event payload for more details on how to retrieve the ID of the invitation.

  • :is_private (boolean)

    Whether the channel should be private.

  • :team_id (Object)

    The ID of the workspace to accept the channel in. If an org-level token is used to call this method, the team_id argument is required.

Raises:

  • (ArgumentError)

See Also:



26
27
28
29
# File 'lib/slack/web/api/endpoints/conversations.rb', line 26

def conversations_acceptSharedInvite(options = {})
  raise ArgumentError, 'Required arguments :channel_name missing' if options[:channel_name].nil?
  post('conversations.acceptSharedInvite', options)
end

#conversations_approveSharedInvite(options = {}) ⇒ Object

Approves an invitation to a Slack Connect channel

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :invite_id (Object)

    ID of the shared channel invite to approve.

  • :target_team (Object)

    The team or enterprise id of the other party involved in the invitation you are approving.

Raises:

  • (ArgumentError)

See Also:



40
41
42
43
# File 'lib/slack/web/api/endpoints/conversations.rb', line 40

def conversations_approveSharedInvite(options = {})
  raise ArgumentError, 'Required arguments :invite_id missing' if options[:invite_id].nil?
  post('conversations.approveSharedInvite', options)
end

#conversations_archive(options = {}) ⇒ Object

Archives a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of conversation to archive.

Raises:

  • (ArgumentError)

See Also:



52
53
54
55
56
# File 'lib/slack/web/api/endpoints/conversations.rb', line 52

def conversations_archive(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.archive', options)
end

#conversations_close(options = {}) ⇒ Object

Closes a direct message or multi-person direct message.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation to close.

Raises:

  • (ArgumentError)

See Also:



65
66
67
68
69
# File 'lib/slack/web/api/endpoints/conversations.rb', line 65

def conversations_close(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.close', options)
end

#conversations_create(options = {}) ⇒ Object

Initiates a public or private channel-based conversation

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :name (string)

    Name of the public or private channel to create.

  • :is_private (boolean)

    Create a private channel instead of a public one.

  • :team_id (string)

    encoded team id to create the channel in, required if org token is used.

Raises:

  • (ArgumentError)

See Also:



82
83
84
85
# File 'lib/slack/web/api/endpoints/conversations.rb', line 82

def conversations_create(options = {})
  raise ArgumentError, 'Required arguments :name missing' if options[:name].nil?
  post('conversations.create', options)
end

#conversations_declineSharedInvite(options = {}) ⇒ Object

Declines a Slack Connect channel invite.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :invite_id (Object)

    ID of the Slack Connect invite to decline. Subscribe to the shared_channel_invite_accepted event to receive IDs of Slack Connect channel invites that have been accepted and are awaiting approval.

  • :target_team (Object)

    The team or enterprise id of the other party involved in the invitation you are declining.

Raises:

  • (ArgumentError)

See Also:



96
97
98
99
# File 'lib/slack/web/api/endpoints/conversations.rb', line 96

def conversations_declineSharedInvite(options = {})
  raise ArgumentError, 'Required arguments :invite_id missing' if options[:invite_id].nil?
  post('conversations.declineSharedInvite', options)
end

#conversations_history(options = {}) ⇒ Object

Fetches a conversation’s history of messages and events.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation ID to fetch history for.

  • :cursor (string)

    Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See pagination for more detail.

  • :include_all_metadata (boolean)

    Return all metadata associated with this message.

  • :inclusive (boolean)

    Include messages with oldest or latest timestamps in results. Ignored unless either timestamp is specified.

  • :latest (timestamp)

    Only messages before this Unix timestamp will be included in results. Default is the current time.

  • :limit (number)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn’t been reached.

  • :oldest (timestamp)

    Only messages after this Unix timestamp will be included in results.

Raises:

  • (ArgumentError)

See Also:



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/slack/web/api/endpoints/conversations.rb', line 120

def conversations_history(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  if block_given?
    Pagination::Cursor.new(self, :conversations_history, options).each do |page|
      yield page
    end
  else
    post('conversations.history', options)
  end
end

#conversations_info(options = {}) ⇒ Object

Retrieve information about a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation ID to learn more about.

  • :include_locale (boolean)

    Set this to true to receive the locale for this conversation. Defaults to false.

  • :include_num_members (boolean)

    Set to true to include the member count for the specified conversation. Defaults to false.

Raises:

  • (ArgumentError)

See Also:



143
144
145
146
147
# File 'lib/slack/web/api/endpoints/conversations.rb', line 143

def conversations_info(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.info', options)
end

#conversations_invite(options = {}) ⇒ Object

Invites users to a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    The ID of the public or private channel to invite user(s) to.

  • :users (string)

    A comma separated list of user IDs. Up to 1000 users may be listed.

  • :force (boolean)

    When set to true and multiple user IDs are provided, continue inviting the valid ones while disregarding invalid IDs. Defaults to false.

Raises:

  • (ArgumentError)

See Also:



160
161
162
163
164
165
# File 'lib/slack/web/api/endpoints/conversations.rb', line 160

def conversations_invite(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :users missing' if options[:users].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.invite', options)
end

#conversations_inviteShared(options = {}) ⇒ Object

Sends an invitation to a Slack Connect channel

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of the channel on your team that you’d like to share.

  • :emails (array)

    Optional email to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.

  • :external_limited (boolean)

    Optional boolean on whether invite is to a external limited member. Defaults to true.

  • :user_ids (array)

    Optional user_id to receive this invite. Either emails or user_ids must be provided. Only one email or one user ID may be invited at a time.

Raises:

  • (ArgumentError)

See Also:



180
181
182
183
184
# File 'lib/slack/web/api/endpoints/conversations.rb', line 180

def conversations_inviteShared(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.inviteShared', options)
end

#conversations_join(options = {}) ⇒ Object

Joins an existing conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of conversation to join.

Raises:

  • (ArgumentError)

See Also:



193
194
195
196
197
# File 'lib/slack/web/api/endpoints/conversations.rb', line 193

def conversations_join(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.join', options)
end

#conversations_kick(options = {}) ⇒ Object

Removes a user from a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of conversation to remove user from.

  • :user (user)

    User ID to be removed.

Raises:

  • (ArgumentError)

See Also:



208
209
210
211
212
213
214
# File 'lib/slack/web/api/endpoints/conversations.rb', line 208

def conversations_kick(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :user missing' if options[:user].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('conversations.kick', options)
end

#conversations_leave(options = {}) ⇒ Object

Leaves a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation to leave.

Raises:

  • (ArgumentError)

See Also:



223
224
225
226
227
# File 'lib/slack/web/api/endpoints/conversations.rb', line 223

def conversations_leave(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.leave', options)
end

#conversations_list(options = {}) ⇒ Object

Lists all channels in a Slack team.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :cursor (string)

    Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See pagination for more detail.

  • :exclude_archived (boolean)

    Set to true to exclude archived channels from the list.

  • :limit (number)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached. Must be an integer under 1000.

  • :team_id (string)

    encoded team id to list channels in, required if token belongs to org-wide app.

  • :types (string)

    Mix and match channel types by providing a comma-separated list of any combination of public_channel, private_channel, mpim, im.

See Also:



244
245
246
247
248
249
250
251
252
# File 'lib/slack/web/api/endpoints/conversations.rb', line 244

def conversations_list(options = {})
  if block_given?
    Pagination::Cursor.new(self, :conversations_list, options).each do |page|
      yield page
    end
  else
    post('conversations.list', options)
  end
end

#conversations_listConnectInvites(options = {}) ⇒ Object

Lists shared channel invites that have been generated or received but have not been approved by all parties

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :cursor (string)

    Set to next_cursor returned by previous call to list items in subsequent page.

  • :team_id (string)

    Encoded team id for the workspace to retrieve invites for, required if org token is used.

See Also:



263
264
265
266
267
268
269
270
271
# File 'lib/slack/web/api/endpoints/conversations.rb', line 263

def conversations_listConnectInvites(options = {})
  if block_given?
    Pagination::Cursor.new(self, :conversations_listConnectInvites, options).each do |page|
      yield page
    end
  else
    post('conversations.listConnectInvites', options)
  end
end

#conversations_mark(options = {}) ⇒ Object

Sets the read cursor in a channel.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel or conversation to set the read cursor for.

  • :ts (timestamp)

    Unique identifier of message you want marked as most recently seen in this conversation.

Raises:

  • (ArgumentError)

See Also:



282
283
284
285
286
287
# File 'lib/slack/web/api/endpoints/conversations.rb', line 282

def conversations_mark(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.mark', options)
end

#conversations_members(options = {}) ⇒ Object

Retrieve members of a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of the conversation to retrieve members for.

  • :cursor (string)

    Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See pagination for more detail.

  • :limit (number)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn’t been reached.

Raises:

  • (ArgumentError)

See Also:



300
301
302
303
304
305
306
307
308
309
310
# File 'lib/slack/web/api/endpoints/conversations.rb', line 300

def conversations_members(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  if block_given?
    Pagination::Cursor.new(self, :conversations_members, options).each do |page|
      yield page
    end
  else
    post('conversations.members', options)
  end
end

#conversations_open(options = {}) ⇒ Object

Opens or resumes a direct message or multi-person direct message.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Resume a conversation by supplying an im or mpim’s ID. Or provide the users field instead.

  • :prevent_creation (boolean)

    Do not create a direct message or multi-person direct message. This is used to see if there is an existing dm or mpdm.

  • :return_im (boolean)

    Boolean, indicates you want the full IM channel definition in the response.

  • :users (string)

    Comma separated lists of users. If only one user is included, this creates a 1:1 DM. The ordering of the users is preserved whenever a multi-person direct message is returned. Supply a channel when not supplying users.

See Also:



325
326
327
328
# File 'lib/slack/web/api/endpoints/conversations.rb', line 325

def conversations_open(options = {})
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.open', options)
end

#conversations_rename(options = {}) ⇒ Object

Renames a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of conversation to rename.

  • :name (string)

    New name for conversation.

Raises:

  • (ArgumentError)

See Also:



339
340
341
342
343
344
# File 'lib/slack/web/api/endpoints/conversations.rb', line 339

def conversations_rename(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :name missing' if options[:name].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.rename', options)
end

#conversations_replies(options = {}) ⇒ Object

Retrieve a thread of messages posted to a conversation

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation ID to fetch thread from.

  • :ts (timestamp)

    Unique identifier of either a thread’s parent message or a message in the thread. ts must be the timestamp of an existing message with 0 or more replies. If there are no replies then just the single message referenced by ts will return - it is just an ordinary, unthreaded message.

  • :cursor (string)

    Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request’s response_metadata. Default value fetches the first “page” of the collection. See pagination for more detail.

  • :include_all_metadata (boolean)

    Return all metadata associated with this message.

  • :inclusive (boolean)

    Include messages with oldest or latest timestamps in results. Ignored unless either timestamp is specified.

  • :latest (timestamp)

    Only messages before this Unix timestamp will be included in results.

  • :limit (number)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn’t been reached.

  • :oldest (timestamp)

    Only messages after this Unix timestamp will be included in results.

Raises:

  • (ArgumentError)

See Also:



367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/slack/web/api/endpoints/conversations.rb', line 367

def conversations_replies(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :ts missing' if options[:ts].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  if block_given?
    Pagination::Cursor.new(self, :conversations_replies, options).each do |page|
      yield page
    end
  else
    post('conversations.replies', options)
  end
end

#conversations_setPurpose(options = {}) ⇒ Object

Sets the purpose for a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation to set the purpose of.

  • :purpose (string)

    A new, specialer purpose.

Raises:

  • (ArgumentError)

See Also:



389
390
391
392
393
394
# File 'lib/slack/web/api/endpoints/conversations.rb', line 389

def conversations_setPurpose(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :purpose missing' if options[:purpose].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.setPurpose', options)
end

#conversations_setTopic(options = {}) ⇒ Object

Sets the topic for a conversation.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Conversation to set the topic of.

  • :topic (string)

    The new topic string. Does not support formatting or linkification.

Raises:

  • (ArgumentError)

See Also:



405
406
407
408
409
410
# File 'lib/slack/web/api/endpoints/conversations.rb', line 405

def conversations_setTopic(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :topic missing' if options[:topic].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.setTopic', options)
end

#conversations_unarchive(options = {}) ⇒ Object

Reverses conversation archival.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    ID of conversation to unarchive.

Raises:

  • (ArgumentError)

See Also:



419
420
421
422
423
# File 'lib/slack/web/api/endpoints/conversations.rb', line 419

def conversations_unarchive(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('conversations.unarchive', options)
end