Xlack.Web.Chat (xlack v0.1.0) View Source
Link to this section Summary
Functions
Deletes a message.
Retrieve a permalink URL for a specific extant message.
Sends an ephemeral message to a channel.
Sends a message to a channel.
Schedules a message to be sent to a channel.
Provide custom unfurl behavior for user-posted URLs.
Updates a message.
Link to this section Functions
Deletes a message.
Required Params
channel- Channel containing the message to be deleted.ts- Timestamp of the message to be deleted. ex:1405894322.002768
Errors the API can return:
cant_delete_message- Authenticated user does not have permission to delete this message.channel_not_found- Value passed forchannelwas invalid.compliance_exports_prevent_deletion- Compliance exports are on, messages can not be deletedmessage_not_found- No message exists with the requested timestamp.
Retrieve a permalink URL for a specific extant message.
Required Params
channel- The ID of the conversation or channel containing the message.message_ts- A message's ts value, uniquely identifying it within a channel. ex:1405894322.002768
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.message_not_found- No message exists with the requested timestamp.
Sends an ephemeral message to a channel.
Required Params
channel- Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.text- Text of the message to send. See below for an explanation of formatting. ex:Hello worlduser-idof the user who will receive the ephemeral message. The user should be in the channel specified by thechannelargument.
Optional Params
as_user- Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below. ex:trueattachments- Structured message attachments. ex:[{"pretext": "pre-hello", "text": "text-world"}]blocks- A JSON-based array of structured blocks, presented as a URL-encoded string ex:[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]link_names- Find and link channel names and usernames. ex:1parse- Change how messages are treated. Defaults tonone. See below. ex:full
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.msg_too_long- Message text is too longno_text- No message text providedrate_limited- Application has posted too many messages, read the Rate Limit documentation for more informationuser_not_in_channel- Cannot post user messages to a channel they are not in.
Sends a message to a channel.
Required Params
channel- Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.text- Text of the message to send. See below for an explanation of formatting. ex:Hello world
Optional Params
as_user- Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below. ex:trueattachments- Structured message attachments. ex:[{"pretext": "pre-hello", "text": "text-world"}]blocks- A JSON-based array of structured blocks, presented as a URL-encoded string ex:[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]icon_emoji- emoji to use as the icon for this message. Overridesicon_url. Must be used in conjunction withas_userset to false, otherwise ignored. See authorship below. ex::chart_with_upwards_trend:icon_url- URL to an image to use as the icon for this message. Must be used in conjunction withas_userset to false, otherwise ignored. See authorship below. ex:http://lorempixel.com/48/48link_names- Find and link channel names and usernames. ex:1parse- Change how messages are treated. Defaults tonone. See below. ex:fullthread_ts- Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead. ex:1234567890.123456unfurl_links- Pass true to enable unfurling of primarily text-based content. ex:trueunfurl_media- Pass false to disable unfurling of media content. ex:falseusername- Set your bot's user name. Must be used in conjunction withas_userset to false, otherwise ignored. See authorship below. ex:My Bot
Errors the API can return:
channel_not_found- Value passed forchannelwas invalid.is_archived- Channel has been archived.msg_too_long- Message text is too longno_text- No message text providednot_in_channel- Cannot post user messages to a channel they are not in.rate_limited- Application has posted too many messages, read the Rate Limit documentation for more information
Schedules a message to be sent to a channel.
Required Params
channel- Channel, private group, or DM channel to send message to. Can be an encoded ID, or a name. ex:C1234567890post_at- Unix EPOCH timestamp of time in future to send the message. ex:299876400
Optional Params
as_user- Pass true to post the message as the authed user, instead of as a bot. Defaults to false. Seechat.postMessage. ex:trueattachments- A JSON-based array of structured attachments, presented as a URL-encoded string. ex:[{"pretext": "pre-hello", "text": "text-world"}]blocks- A JSON-based array of structured blocks, presented as a URL-encoded string. ex:[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]link_names- Find and link channel names and usernames. ex:trueparse- Change how messages are treated. Defaults to none. Seechat.postMessage. ex:fullreply_broadcast- Used in conjunction withthread_tsand indicates whether reply should be made visible to everyone in the channel or conversation. Defaults tofalse. ex:truethread_ts- Provide another message'stsvalue to make this message a reply. Avoid using a reply'stsvalue; use its parent instead. ex:1234567890.123456unfurl_links- Pass true to enable unfurling of primarily text-based content. ex:trueunfurl_media- Pass false to disable unfurling of media content. ex:false
Errors the API can return:
account_inactive- Authentication token is for a deleted user or workspace.channel_not_found- Value passed forchannelwas invalid.ekm_access_denied- Administrators have suspended the ability to post a message.fatal_error- The server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.invalid_arg_name- The method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.invalid_arguments- The method was called with invalid arguments.invalid_auth- Some aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.invalid_charset- The method was called via aPOSTrequest, but thecharsetspecified in theContent-Typeheader was invalid. Valid charset names are:utf-8iso-8859-1.invalid_form_data- The method was called via aPOSTrequest withContent-Typeapplication/x-www-form-urlencodedormultipart/form-data, but the form data was either missing or syntactically invalid.invalid_post_type- The method was called via aPOSTrequest, but the specifiedContent-Typewas invalid. Valid types are:application/jsonapplication/x-www-form-urlencodedmultipart/form-datatext/plain.invalid_time- value passed forpost_timewas invalid.is_archived- Channel has been archived.missing_post_type- The method was called via aPOSTrequest and included a data payload, but the request did not include aContent-Typeheader.missing_scope- The token used is not granted the specific scope permissions required to complete this request.msg_too_long- Message text is too longno_permission- The workspace token used in this request does not have the permissions necessary to complete the request. Make sure your app is a member of the conversation it's attempting to post a message to.no_text- No message text providednot_authed- No authentication token provided.not_in_channel- Cannot post user messages to a channel they are not in.org_login_required- The workspace is undergoing an enterprise migration and will not be available until migration is complete.rate_limited- Application has posted too many messages, read the Rate Limit documentation for more informationrequest_timeout- The method was called via aPOSTrequest, but thePOSTdata was either missing or truncated.restricted_action- A workspace preference prevents the authenticated user from posting.restricted_action_non_threadable_channel- Cannot post thread replies into a non_threadable channel.restricted_action_read_only_channel- Cannot post any message into a read-only channel.restricted_action_thread_only_channel- Cannot post top-level messages into a thread-only channel.team_added_to_org- The workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.time_in_past- value passed forpost_timewas in the past.time_too_far- value passed forpost_timewas too far into the future.token_revoked- Authentication token is for a deleted user or workspace or the app has been removed.too_many_attachments- Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message.
Provide custom unfurl behavior for user-posted URLs.
Required Params
channel- Channel ID of the message. ex:C1234567890ts- Timestamp of the message to add unfurl behavior to. ex:1405894322.002768unfurls- URL-encoded JSON map with keys set to URLs featured in the the message, pointing to their unfurl blocks or message attachments.
Optional Params
user_auth_message- Provide a simply-formatted string to send as an ephemeral message to the user as invitation to authenticate further and enable full unfurling behavior.user_auth_required- Set to true or 1 to indicate the user must install your Xlack app to trigger unfurls for this domain. ex:trueuser_auth_url- Send users to this custom URL where they will complete authentication in your app to fully trigger unfurling. Value should be properly URL-encoded.. ex:https://example.com/onboarding?user_id=xxx
Errors the API can return:
method_deprecated- The method has been deprecated.cannot_find_channel- The specified channel could not be located for this token.cannot_unfurl_message- The URL cannot be unfurled because the URL provided does not appear in the message.invalid_charset- The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.request_timeout- The method was called via a POST request, but the POST data was either missing or truncated.missing_post_type- The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.service_unavailable- The service is temporarily unavailableratelimited- The request has been ratelimited. Refer to the Retry-After header for when to retry the request.no_permission- The workspace token used in this request does not have the permissions necessary to complete the request. Make sure your app is a member of the conversation it's attempting to post a message to.two_factor_setup_required- Two factor setup is required.invalid_arguments- The method was either called with invalid arguments or some detail about the arguments passed are invalid, which is more likely when using complex arguments like blocks or attachments.invalid_auth- Some aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.not_allowed_token_type- The token type used in this request is not allowed.org_login_required- The workspace is undergoing an enterprise migration and will not be available until migration is complete.cannot_prompt- The current user has already interacted with and dismissed a prompt for this application.invalid_unfurls_format- The unfurls parameter cannot be JSON-decoded into a map of URLs to attachments.missing_ts- The request is missing the ts parameterenterprise_is_restricted- The method cannot be called from an Enterprise.cannot_parse_attachment- The provided unfurls argument could not be parsed or understood.accesslimited- Access to this method is limited on the current networkinvalid_form_data- The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.cannot_unfurl_url- The URL cannot be unfurled. This error may be returned if you haven't acknowledged a link_shared event tied to the same URL. It is also returned when the domain appears in a workspace's administrative blacklists.invalid_array_arg- The method was passed an array as an argument. Please only input valid strings.deprecated_endpoint- The endpoint has been deprecated.token_revoked- Authentication token is for a deleted user or workspace or the app has been removed.cannot_find_service- A record of your app being allowed to unfurl for this workspace could not be found.invalid_post_type- The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/json application/x-www-form-urlencoded multipart/form-data text/plain.missing_channel- The request is missing the channel parameterinvalid_arg_name- The method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.is_bot- This method cannot be called by a bot user.team_added_to_org- The workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.missing_unfurls- The request is missing the unfurls parameter.not_authed- No authentication token provided.fatal_error- The server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.cannot_find_message- The ts value in the request does not match a message.account_inactive- Authentication token is for a deleted user or workspace.internal_error- The server could not complete your operation(s) without encountering an error, likely due to a transient issue on our end. It's possible some aspect of the operation succeeded before the error was raised.ekm_access_denied- Administrators have suspended the ability to post a message.missing_scope- The token used is not granted the specific scope permissions required to complete this request.
Updates a message.
Required Params
channel- Channel containing the message to be updated.ts- Timestamp of the message to be updated. ex:1405894322.002768
Optional Params
as_user- Pass true to update the message as the authed user. Bot users in this context are considered authed users. ex:trueattachments- Structured message attachments. ex:[{"pretext": "pre-hello", "text": "text-world"}]blocks- A JSON-based array of structured blocks, presented as a URL-encoded string. If you don't include this field, the message's previousblockswill be retained. To remove previousblocks, include an empty array for this field. ex:[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]link_names- Find and link channel names and usernames. Defaults tonone. This parameter should be used in conjunction withparse. To setlink_namesto1, specify aparsemode offull. ex:1parse- Change how messages are treated. Defaults toclient, unlikechat.postMessage. See below. ex:nonetext- New text for the message, using the default formatting rules. It's not required when presenting blocks or attachments. ex:Hello world
Errors the API can return:
cant_update_message- Authenticated user does not have permission to update this message.channel_not_found- Value passed forchannelwas invalid.edit_window_closed- The message cannot be edited due to the team message edit settingsmessage_not_found- No message exists with the requested timestamp.msg_too_long- Message text is too longno_text- No message text provided