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

doc: make events in the document clearer #1046

Merged
merged 3 commits into from Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_advanced/authorization.md
Expand Up @@ -6,11 +6,11 @@ order: 2
---

<div class="section-content">
Authorization is the process of deciding which Slack credentials (such as a bot token) should be available while processing a specific incoming event.
Authorization is the process of deciding which Slack credentials (such as a bot token) should be available while processing a specific incoming request.

Custom apps installed on a single workspace can simply use the `token` option at the time of `App` initialization. However, when your app needs to handle several tokens, such as cases where it will be installed on multiple workspaces or needs access to more than one user token, the `authorize` option should be used instead. <b>If you're using the [built-in OAuth support](#authenticating-oauth) authorization is handled by default, so you do not need to pass in an `authorize` option.</b>

The `authorize` option can be set to a function that takes an event source as its input, and should return a Promise for an object containing the authorized credentials. The source contains information about who and where the event is coming from by using properties like `teamId` (always available), `userId`, `conversationId`, and `enterpriseId`.
The `authorize` option can be set to a function that takes an event source as its input, and should return a Promise for an object containing the authorized credentials. The source contains information about who and where the request is coming from by using properties like `teamId` (always available), `userId`, `conversationId`, and `enterpriseId`.

The authorized credentials should also have a few specific properties: `botToken`, `userToken`, `botId` (required for an app to ignore messages from itself), and `botUserId`. You can also include any other properties you'd like to make available on the [`context`](#context) object.

Expand Down
2 changes: 1 addition & 1 deletion docs/_advanced/context.md
Expand Up @@ -6,7 +6,7 @@ order: 7
---

<div class="section-content">
All listeners have access to a `context` object, which can be used to enrich events with additional information. For example, perhaps you want to add user information from a third party system or add temporary state for the next middleware in the chain.
All listeners have access to a `context` object, which can be used to enrich requests with additional information. For example, perhaps you want to add user information from a third party system or add temporary state for the next middleware in the chain.

`context` is just an object, so you can add to it by setting it to a modified version of itself.
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_advanced/middleware_global.md
Expand Up @@ -6,7 +6,7 @@ order: 5
---

<div class="section-content">
Global middleware is run for all incoming events before any listener middleware. You can add any number of global middleware to your app by utilizing `app.use(fn)`. The middleware function `fn` is called with the same arguments as listeners and an additional `next` function.
Global middleware is run for all incoming requests before any listener middleware. You can add any number of global middleware to your app by utilizing `app.use(fn)`. The middleware function `fn` is called with the same arguments as listeners and an additional `next` function.
filmaj marked this conversation as resolved.
Show resolved Hide resolved

Both global and listener middleware must call `await next()` to pass control of the execution chain to the next middleware, or call `throw` to pass an error back up the previously-executed middleware chain.

Expand All @@ -16,7 +16,7 @@ As an example, let's say your app should only respond to users identified with a
</div>

```javascript
// Authentication middleware that associates incoming event with user in Acme identity provider
// Authentication middleware that associates incoming request with user in Acme identity provider
async function authWithAcme({ payload, client, context, next }) {
const slackUserId = payload.user;
const helpChannelId = 'C12345';
Expand All @@ -29,7 +29,7 @@ async function authWithAcme({ payload, client, context, next }) {
// When the user lookup is successful, add the user details to the context
context.user = user;
} catch (error) {
// This user wasn't found in Acme. Send them an error and don't continue processing event
// This user wasn't found in Acme. Send them an error and don't continue processing request
if (error.message === 'Not Found') {
await client.chat.postEphemeral({
channel: payload.channel,
Expand Down
4 changes: 2 additions & 2 deletions docs/_basic/acknowledging_requests.md
@@ -1,12 +1,12 @@
---
title: Acknowledging events
title: Acknowledging requests
lang: en
slug: acknowledge
order: 7
---

<div class="section-content">
Actions, commands, and options events must **always** be acknowledged using the `ack()` function. This lets Slack know that the event was received and updates the Slack user interface accordingly. Depending on the type of event, your acknowledgement may be different. For example, when acknowledging a modal submission you will call `ack()` with validation errors if the submission contains errors, or with no parameters if the submission is valid.
Actions, commands, and options requests must **always** be acknowledged using the `ack()` function. This lets Slack know that the request was received and updates the Slack user interface accordingly. Depending on the type of request, your acknowledgement may be different. For example, when acknowledging a modal submission you will call `ack()` with validation errors if the submission contains errors, or with no parameters if the submission is valid.

We recommend calling `ack()` right away before sending a new message or fetching information from your database since you only have 3 seconds to respond.
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/listening_actions.md
Expand Up @@ -10,7 +10,7 @@ Your app can listen to user actions like button clicks, and menu selects, using

Actions can be filtered on an `action_id` of type string or RegExp object. `action_id`s act as unique identifiers for interactive components on the Slack platform.

You’ll notice in all `action()` examples, `ack()` is used. It is required to call the `ack()` function within an action listener to acknowledge that the event was received from Slack. This is discussed in the [acknowledging events section](#acknowledge).
You’ll notice in all `action()` examples, `ack()` is used. It is required to call the `ack()` function within an action listener to acknowledge that the request was received from Slack. This is discussed in the [acknowledging requests section](#acknowledge).

*Note: Since v2, message shortcuts (previously message actions) now use the `shortcut()` method instead of the `action()` method. View the [migration guide for V2](https://slack.dev/bolt/tutorial/migration-v2) to learn about the changes.*
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_basic/listening_modals.md
Expand Up @@ -6,7 +6,7 @@ order: 12
---

<div class="section-content">
If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> contains any input blocks, you must listen to <code>view_submission</code> events to receive their values. To listen to <code>view_submission</code> events, you can use the built-in <code>view()</code> method.
If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> contains any input blocks, you must listen to <code>view_submission</code> requests to receive their values. To listen to <code>view_submission</code> requests, you can use the built-in <code>view()</code> method.

<code>view()</code> requires a <code>callback_id</code> of type <code>string</code> or <code>RegExp</code>.

Expand All @@ -16,9 +16,9 @@ Read more about view submissions in our <a href="https://api.slack.com/surfaces/
</div>

```javascript
// Handle a view_submission event
// Handle a view_submission request
app.view('view_b', async ({ ack, body, view, client }) => {
// Acknowledge the view_submission event
// Acknowledge the view_submission request
await ack();

// Do whatever you want with the input data - here we're saving it to a DB then sending the user a verifcation of their submission
Expand Down
4 changes: 2 additions & 2 deletions docs/_basic/listening_responding_commands.md
Expand Up @@ -6,11 +6,11 @@ order: 9
---

<div class="section-content">
Your app can use the `command()` method to listen to incoming slash command events. The method requires a `commandName` of type string or RegExp.
Your app can use the `command()` method to listen to incoming slash command requests. The method requires a `commandName` of type string or RegExp.

⚠️ Note that if you use `command()` multiple times with overlapping RegExp matches, _all_ matching listeners will run. Design your regular expressions to avoid this possibility.

Commands must be acknowledged with `ack()` to inform Slack your app has received the event.
Commands must be acknowledged with `ack()` to inform Slack your app has received the request.

There are two ways to respond to slash commands. The first way is to use `say()`, which accepts a string or JSON payload. The second is `respond()` which is a utility for the `response_url`. These are explained in more depth in the [responding to actions](#action-respond) section.

Expand Down
4 changes: 2 additions & 2 deletions docs/_basic/listening_responding_shortcuts.md
Expand Up @@ -9,11 +9,11 @@ order: 8

The `shortcut()` method supports both [global shortcuts](https://api.slack.com/interactivity/shortcuts/using#global_shortcuts) and [message shortcuts](https://api.slack.com/interactivity/shortcuts/using#message_shortcuts).

Shortcuts are invokable entry points to apps. Global shortcuts are available from within search in Slack. Message shortcuts are available in the context menus of messages. Your app can use the `shortcut()` method to listen to incoming shortcut events. The method requires a `callback_id` parameter of type `string` or `RegExp`.
Shortcuts are invokable entry points to apps. Global shortcuts are available from within search in Slack. Message shortcuts are available in the context menus of messages. Your app can use the `shortcut()` method to listen to incoming shortcut requests. The method requires a `callback_id` parameter of type `string` or `RegExp`.

⚠️ Note that if you use `shortcut()` multiple times with overlapping RegExp matches, _all_ matching listeners will run. Design your regular expressions to avoid this possibility.

Shortcuts must be acknowledged with `ack()` to inform Slack that your app has received the event.
Shortcuts must be acknowledged with `ack()` to inform Slack that your app has received the request.

Shortcuts include a `trigger_id` which an app can use to [open a modal](#creating-modals) that confirms the action the user is taking.

Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/responding_actions.md
Expand Up @@ -6,7 +6,7 @@ order: 6
---

<div class="section-content">
There are two main ways to respond to actions. The first (and most common) way is to use the `say` function. The `say` function sends a message back to the conversation where the incoming event took place.
There are two main ways to respond to actions. The first (and most common) way is to use the `say` function. The `say` function sends a message back to the conversation where the incoming request took place.

The second way to respond to actions is using `respond()`, which is a simple utility to use the `response_url` associated with an action.
</div>
Expand Down