You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Slack platform offers features tailored for AI agents and assistants. Your apps can [utilize the `Assistant` class](#assistant) for a side-panel view designed with AI in mind, or they can utilize features applicable to messages throughout Slack, like [chat streaming](#text-streaming) and [feedback buttons](#adding-and-handling-feedback).
5
5
@@ -63,7 +63,7 @@ If you do provide your own `threadContextStore` property, it must feature `get`
63
63
:::tip[Refer to the [reference docs](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments.]
64
64
:::
65
65
66
-
### Configuring your app to support the `Assistant` class
66
+
### Configuring your app to support the `Assistant` class {#configuring-assistant-class}
67
67
68
68
1. Within [App Settings](https://api.slack.com/apps), enable the **Agents & AI Apps** feature.
69
69
@@ -122,7 +122,7 @@ def start_assistant_thread(
122
122
123
123
You can send more complex messages to the user — see [Sending Block Kit alongside messages](#block-kit-interactions) for more info.
When the user switches channels, the [`assistant_thread_context_changed`](/reference/events/assistant_thread_context_changed) event will be sent to your app.
128
128
@@ -137,7 +137,7 @@ from slack_bolt import FileAssistantThreadContextStore
For advanced use cases, Block Kit buttons may be used instead of suggested prompts, as well as the sending of messages with structured [metadata](/messaging/message-metadata/) to trigger subsequent interactions with the user.
211
+
212
+
For example, an app can display a button such as "Summarize the referring channel" in the initial reply. When the user clicks the button and submits detailed information (such as the number of messages, days to check, purpose of the summary, etc.), the app can handle that information and post a message that describes the request with structured metadata.
213
+
214
+
By default, apps can't respond to their own bot messages (Bolt prevents infinite loops by default). However, if you pass `ignoring_self_assistant_message_events_enabled=False` to the `App` constructor and add a `bot_message` listener to your `Assistant` middleware, your app can continue processing the request as shown below:
## Adding and handling feedback {#adding-and-handling-feedback}
289
417
290
418
Use the [feedback buttons block element](/reference/block-kit/block-elements/feedback-buttons-element/) to allow users to immediately provide feedback regarding your app's responses. Here's a quick example:
For advanced use cases, Block Kit buttons may be used instead of suggested prompts, as well as the sending of messages with structured [metadata](/messaging/message-metadata/) to trigger subsequent interactions with the user.
387
-
388
-
For example, an app can display a button such as "Summarize the referring channel" in the initial reply. When the user clicks the button and submits detailed information (such as the number of messages, days to check, purpose of the summary, etc.), the app can handle that information and post a message that describes the request with structured metadata.
389
-
390
-
By default, apps can't respond to their own bot messages (Bolt prevents infinite loops by default). However, if you pass `ignoring_self_assistant_message_events_enabled=False` to the `App` constructor and add a `bot_message` listener to your `Assistant` middleware, your app can continue processing the request as shown below:
if payload.get("metadata", {}).get("event_type") =="assistant-generate-random-numbers":
492
-
# Handle the above random-number-generation request
493
-
set_status("is generating an array of random numbers...")
494
-
time.sleep(1)
495
-
nums: Set[str] =set()
496
-
num = payload["metadata"]["event_payload"]["num"]
497
-
whilelen(nums) < num:
498
-
nums.add(str(random.randint(1, 100)))
499
-
say(f"Here you are: {', '.join(nums)}")
500
-
else:
501
-
# nothing to do for this bot message
502
-
# If you want to add more patterns here, be careful not to cause infinite loop messaging
503
-
pass
504
-
505
-
exceptExceptionas e:
506
-
logger.exception(f"Failed to respond to an inquiry: {e}")
507
-
...
508
-
```
509
-
510
-
## Full example: App Agent Template
510
+
## Full example: App Agent Template {#app-agent-template}
511
511
512
512
Want to see the functionality described throughout this guide in action? We've created a [App Agent Template](https://github.com/slack-samples/bolt-python-assistant-template) repo for you to build off of.
0 commit comments