X Tutup
Skip to content

Commit 2519e4e

Browse files
misscodedseratch
authored andcommitted
update docs > basics with shay feedback
1 parent 4958dab commit 2519e4e

11 files changed

+50
-47
lines changed

docs/_basic/authenticating_oauth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ order: 14
77

88
<div class="section-content">
99

10-
Slack apps installed on multiple workspaces will need to implement OAuth, then store installation information (like access tokens) securely. By providing `client_id`, `client_secret`, `scopes`, `installation_store`, and `state_store` when initializing App, Bolt for Python will handle the work of setting up OAuth routes and verifying state. If you’re implementing a custom receiver, you can make use of our [OAuth library](https://slack.dev/python-slack-sdk/oauth), which is what Bolt for Python uses under the hood.
10+
Slack apps installed on multiple workspaces will need to implement OAuth, then store installation information (like access tokens) securely. By providing `client_id`, `client_secret`, `scopes`, `installation_store`, and `state_store` when initializing App, Bolt for Python will handle the work of setting up OAuth routes and verifying state. If you’re implementing a custom receiver, you can make use of our [OAuth library](https://slack.dev/python-slack-sdk/oauth/), which is what Bolt for Python uses under the hood.
1111

1212
Bolt for Python will create a **Redirect URL** `slack/oauth_redirect`, which Slack uses to redirect users after they complete your app’s installation flow. You will need to add this **Redirect URL** in your app configuration settings under **OAuth and Permissions**. This path can be configured in the `OAuthSettings` argument described below.
1313

docs/_basic/listening_actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ order: 5
66
---
77

88
<div class="section-content">
9-
Your app can listen to user actions like button clicks, and menu selects, using the `action` method.
9+
Your app can listen to user actions, like button clicks, and menu selects, using the `action` method.
1010

1111
Actions can be filtered on an `action_id` of type `str` or `re.Pattern`. `action_id`s act as unique identifiers for interactive components on the Slack platform.
1212

docs/_basic/listening_events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ order: 3
77

88
<div class="section-content">
99

10-
You can listen to [any Events API event](https://api.slack.com/events) using the `event()` method after subscribing to it in your app configuration. This allows your app to take action when something happens in Slack, like a user reacting to a message or joining a channel.
10+
You can listen to [any Events API event](https://api.slack.com/events) using the `event()` method after subscribing to it in your app configuration. This allows your app to take action when something happens in a workspace where it's installed, like a user reacting to a message or joining a channel.
1111

1212
The `event()` method requires an `eventType` of type `str`.
1313

docs/_basic/listening_modals.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,28 @@ Read more about view submissions in our <a href="https://api.slack.com/surfaces/
1717

1818
```python
1919
# Handle a view_submission event
20-
@app.view("view_b")
21-
def handle_submission(ack, body, client, view):
22-
# Acknowledge the view_submission event
23-
ack()
24-
25-
# 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
26-
27-
# Assume there's an input block with `block_1` as the block_id and `input_a`
28-
val = view["state"]["values"]["block_1"]["input_a"]
29-
user = body["user"]["id"]
30-
31-
# Message to send user
32-
msg = ""
33-
34-
# TODO: Store in DB
35-
36-
if results:
37-
msg = "Your submission was successful"
38-
else:
39-
msg = "There was an error with your submission"
40-
41-
# Message the user
42-
client.chat_postMessage(channel=user, text=msg)
20+
​​@app.view("view_b")
21+
​​def handle_submission(ack, body, client, view):
22+
​​ # Acknowledge the view_submission event
23+
​​ ack()
24+
​​
25+
​​ # Do whatever you want with the input data - here we're saving it to a DB
26+
# then sending the user a verifcation of their submission
27+
​​
28+
​​ # Assume there's an input block with `block_1` as the block_id and `input_a`
29+
​​ val = view["state"]["values"]["block_1"]["input_a"]
30+
​​ user = body["user"]["id"]
31+
​​
32+
​​ # Message to send user
33+
​​ msg = ""
34+
​​
35+
​​ try:
36+
​​ # Save to DB
37+
​​ msg = f"Your submission of {val} was successful"
38+
​​ except Exception as e:
39+
​​ # Handle error
40+
​​ msg = "There was an error with your submission"
41+
​​ finally:
42+
​​ # Message the user
43+
​​ client.chat_postMessage(channel=user, text=msg)
4344
```

docs/_basic/listening_responding_commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Commands must be acknowledged with `ack()` to inform Slack your app has received
1313

1414
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.
1515

16-
When configuring commands within your app configuration, you'll continue to append `/slack/events` to your request URL.
16+
When setting up commands within your app configuration, you'll append `/slack/events` to your request URL.
1717

1818
</div>
1919

docs/_basic/listening_responding_options.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ order: 13
77

88
<div class="section-content">
99
The `options()` method listens for incoming option request payloads from Slack. [Similar to `action()`](#action-listening),
10-
an `action_id` or constraints object is required. In order to load external data into your select menus, you must provide an options load URL in your app configuration.
10+
an `action_id` or constraints object is required. In order to load external data into your select menus, you must provide an options load URL in your app configuration, appended with `/slack/events`.
1111

12-
While it's recommended to use `action_id` for `external_select` menus, dialogs do not yet support Block Kit so you'll have to
13-
use the constraints object to filter on a `callback_id`.
12+
While it's recommended to use `action_id` for `external_select` menus, dialogs do not support Block Kit so you'll have to use the constraints object to filter on a `callback_id`.
13+
14+
To respond to options requests, you'll need to call `ack()` with a valid `options` or `option_groups` list. Both [external select response examples](https://api.slack.com/reference/messaging/block-elements#external-select) and [dialog response examples](https://api.slack.com/dialogs#dynamic_select_elements_external) can be found on our API site.
1415

15-
To respond to options requests, you'll need to `ack()` with valid options. Both [external select response examples](https://api.slack.com/reference/messaging/block-elements#external-select) and [dialog response examples](https://api.slack.com/dialogs#dynamic_select_elements_external) can be found on our API site.
1616
</div>
1717

1818
```python
@@ -29,6 +29,5 @@ def show_options(ack):
2929
"value": "1-2",
3030
},
3131
]
32-
3332
ack(options=options)
3433
```

docs/_basic/listening_responding_shortcuts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Shortcuts must be acknowledged with `ack()` to inform Slack that your app has re
1515

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

18-
When configuring shortcuts within your app configuration, you'll continue to append `/slack/events` to your request URL.
18+
When setting up shortcuts within your app configuration, as with other URLs, you'll append `/slack/events` to your request URL.
1919

20-
⚠️ Note that global shortcuts do **not** include a channel ID. If your app needs access to a channel ID, you may use a [`conversations_select`](https://api.slack.com/reference/block-kit/block-elements#conversation_select) element within a modal. Message shortcuts do include channel ID.
20+
⚠️ Note that global shortcuts do **not** include a channel ID. If your app needs access to a channel ID, you may use a [`conversations_select`](https://api.slack.com/reference/block-kit/block-elements#conversation_select) element within a modal. Message shortcuts do include a channel ID.
2121

2222
</div>
2323

docs/_basic/opening_modals.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ order: 10
66
---
77

88
<div class="section-content">
9-
<a href="https://api.slack.com/block-kit/surfaces/modals">Modals</a> are focused surfaces that allow you to collect user data and display dynamic information. You can open a modal by passing a valid <code>trigger_id</code> and a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> to the built-in client's <a href="https://api.slack.com/methods/views.open"><code>views.open</code></a> method.
109

11-
Your app receives <code>trigger_id</code>s in payloads sent to your Request URL triggered user invocation like a slash command, button press, or interaction with a select menu.
10+
<a href="https://api.slack.com/block-kit/surfaces/modals">Modals</a> are focused surfaces that allow you to collect user data and display dynamic information. You can open a modal by passing a valid `trigger_id` and a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> to the built-in client's <a href="https://api.slack.com/methods/views.open">`views.open`</a> method.
11+
12+
Your app receives `trigger_id`s in payloads sent to your Request URL that are triggered by user invocations, like a shortcut, button press, or interaction with a select menu.
1213

1314
Read more about modal composition in the <a href="https://api.slack.com/surfaces/modals/using#composing_views">API documentation</a>.
1415

1516
</div>
1617

1718
```python
18-
# Listen for a slash command invocation
19-
@app.command("/ticket")
19+
# Listen for a shortcut invocation
20+
@app.shortcut("open_modal")
2021
def open_modal(ack, body, client):
2122
# Acknowledge the command request
2223
ack();
2324

2425
# Call views_open with the built-in client
25-
client.views_open({
26+
client.views_open(
2627
# Pass a valid trigger_id within 3 seconds of receiving it
2728
trigger_id=body["trigger_id"],
2829
# View payload
@@ -69,5 +70,5 @@ def open_modal(ack, body, client):
6970
"text": "Submit"
7071
}
7172
}
72-
})
73+
)
7374
```

docs/_basic/responding_actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ order: 6
99

1010
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.
1111

12-
The second way to respond to actions is using `respond()`, which is a simple utility to use the `response_url` associated with an action.
12+
The second way to respond to actions is using `respond()`, which is a utility to use the `response_url` associated with the action.
1313

1414
</div>
1515

docs/_basic/updating_pushing_modals.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ order: 11
99

1010
Modals contain a stack of views. When you call <a href="https://api.slack.com/methods/views.open">`views_open`</a>, you add the root view to the modal. After the initial call, you can dynamically update a view by calling <a href="https://api.slack.com/methods/views.update">`views_update`</a>, or stack a new view on top of the root view by calling <a href="https://api.slack.com/methods/views.push">`views_push`</a>.
1111

12-
<strong><code>views_update</code></strong><br>
13-
To update a view, you can use the built-in client to call <code>views_update</code> with the <code>view_id</code> that was generated when you opened the view, and a new <code>view</code> including the updated <code>blocks</code> array. If you're updating the view when a user interacts with an element inside of an existing view, the <code>view_id</code> will be available in the <code>body</code> of the request.
12+
**`views_update`**<br>
13+
To update a view, you can use the built-in client to call `views_update` with the `view_id` that was generated when you opened the view, and a new `view` including the updated `blocks` list. If you're updating the view when a user interacts with an element inside of an existing view, the `view_id` will be available in the `body` of the request.
1414

15-
<strong><code>views_push</code></strong><br>
16-
To push a new view onto the view stack, you can use the built-in client to call <code>views_push</code> with a valid <code>trigger_id</code> a new <a href="https://api.slack.com/reference/block-kit/views">view payload</a>. The arguments for `views_push` is the same as <a href="#creating-modals">opening modals</a>. After you open a modal, you may only push two additional views onto the view stack.
15+
**`views_push`**<br>
16+
To push a new view onto the view stack, you can use the built-in client to call `views_push` with a valid `trigger_id` a new <a href="https://api.slack.com/reference/block-kit/views">view payload</a>. The arguments for `views_push` is the same as <a href="#creating-modals">opening modals</a>. After you open a modal, you may only push two additional views onto the view stack.
1717

1818
Learn more about updating and pushing views in our <a href="https://api.slack.com/surfaces/modals/using#modifying">API documentation</a>.
1919

@@ -28,6 +28,8 @@ def update_modal(ack, view, client):
2828
client.views_update(
2929
# Pass the view_id
3030
view_id=view["id"],
31+
# String that represents view state to protect against race conditions
32+
hash=view["hash"],
3133
# View payload with updated blocks
3234
view={
3335
"type": "modal",

0 commit comments

Comments
 (0)
X Tutup