Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions listeners/assistant/assistant_thread_started.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from logging import Logger

from slack_bolt import Say, SetSuggestedPrompts
from slack_bolt import BoltAgent, Say
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩



def assistant_thread_started(
say: Say,
set_suggested_prompts: SetSuggestedPrompts,
agent: BoltAgent,
logger: Logger,
say: Say,
):
"""
Handle the assistant thread start event by greeting the user and setting suggested prompts.
Expand All @@ -18,7 +18,7 @@ def assistant_thread_started(
"""
try:
say("What would you like to do today?")
set_suggested_prompts(
agent.set_suggested_prompts(
prompts=[
{
"title": "Prompt a task with thinking steps",
Expand Down
21 changes: 4 additions & 17 deletions listeners/assistant/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from logging import Logger

from openai.types.responses import ResponseInputParam
from slack_bolt import BoltAgent, BoltContext, Say, SetStatus
from slack_sdk import WebClient
from slack_bolt import BoltAgent, Say
from slack_sdk.models.messages.chunk import (
MarkdownTextChunk,
PlanUpdateChunk,
Expand All @@ -16,36 +15,24 @@

def message(
agent: BoltAgent,
client: WebClient,
context: BoltContext,
logger: Logger,
message: dict,
payload: dict,
say: Say,
set_status: SetStatus,
):
"""
Handles when users send messages or select a prompt in an assistant thread and generate AI responses:

Args:
agent: BoltAgent for making API calls
client: Slack WebClient for making API calls
context: Bolt context containing channel and thread information
logger: Logger instance for error tracking
payload: Event payload with message details (channel, user, text, etc.)
message: Dictionary with message information
say: Function to send messages to the thread
set_status: Function to update the assistant's status
"""
Comment on lines 26 to 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this diff omg 🤩

try:
channel_id = payload["channel"]
team_id = context.team_id
thread_ts = payload["thread_ts"]
user_id = context.user_id

# The first example shows a message with thinking steps that has different
# chunks to construct and update a plan alongside text outputs.
if message["text"] == "Wonder a few deep thoughts.":
set_status(
agent.set_status(
status="thinking...",
loading_messages=[
"Teaching the hamsters to type faster…",
Expand Down Expand Up @@ -125,7 +112,7 @@ def message(
# This second example shows a generated text response for a provided prompt
# displayed as a timeline.
else:
set_status(
agent.set_status(
status="thinking...",
loading_messages=[
"Teaching the hamsters to type faster…",
Expand Down
17 changes: 7 additions & 10 deletions listeners/events/app_mentioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@

from openai.types.responses import ResponseInputParam
from slack_bolt import BoltAgent, Say
from slack_sdk import WebClient

from agent.llm_caller import call_llm
from listeners.views.feedback_block import create_feedback_block


def app_mentioned_callback(agent: BoltAgent, client: WebClient, event: dict, logger: Logger, say: Say):
def app_mentioned_callback(
agent: BoltAgent,
event: dict,
logger: Logger,
say: Say,
):
"""
Handles the event when the app is mentioned in a Slack conversation
and generates an AI response.

Args:
agent: BoltAgent for making API calls
client: Slack WebClient for making API calls
event: Event payload containing mention details (channel, user, text, etc.)
logger: Logger instance for error tracking
say: Function to send messages to the thread from the app
"""
try:
channel_id = event.get("channel")
team_id = event.get("team")
text = event.get("text")
thread_ts = event.get("thread_ts") or event.get("ts")
user_id = event.get("user")

client.assistant_threads_setStatus(
channel_id=channel_id,
thread_ts=thread_ts,
agent.set_status(
status="thinking...",
loading_messages=[
"Teaching the hamsters to type faster…",
Expand Down