Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created January 6, 2026 14:41
Show Gist options
  • Select an option

  • Save larkintuckerllc/857b7e7fff960083642d83360b20cd58 to your computer and use it in GitHub Desktop.

Select an option

Save larkintuckerllc/857b7e7fff960083642d83360b20cd58 to your computer and use it in GitHub Desktop.
diff --git a/app.py b/app.py
index 2cca6b4..c41525a 100644
--- a/app.py
+++ b/app.py
@@ -1,4 +1,6 @@
import os
+import threading
+import time
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
@@ -6,6 +8,10 @@ from slack_sdk.errors import SlackApiError
app = App(token=os.environ.get("SLACK_BOT_TOKEN"))
+def thinking(client, channel_id, thread_ts):
+ time.sleep(30)
+ client.chat_postMessage(channel=channel_id, thread_ts=thread_ts, text="Thought about it.")
+
@app.command("/agent")
def handle_agent_command(ack, command, client, respond):
ack()
@@ -15,6 +21,7 @@ def handle_agent_command(ack, command, client, respond):
try:
result = client.chat_postMessage(channel=channel_id, text=message)
client.chat_postMessage(channel=channel_id, thread_ts=result["ts"], text="Thinking...")
+ threading.Thread(target=thinking, args=(client, channel_id, result["ts"])).start()
except SlackApiError as e:
error = e.response["error"]
if error == "not_in_channel":
@@ -22,6 +29,7 @@ def handle_agent_command(ack, command, client, respond):
client.conversations_join(channel=channel_id)
result = client.chat_postMessage(channel=channel_id, text=message)
client.chat_postMessage(channel=channel_id, thread_ts=result["ts"], text="Thinking...")
+ threading.Thread(target=thinking, args=(client, channel_id, result["ts"])).start()
except SlackApiError as join_error:
respond(f"Something went wrong: {join_error.response['error']}")
elif error == "channel_not_found":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment