Building an AI-Powered Slack Bot

Building a genuinely useful AI-powered Slack bot combines Slack’s event API with an LLM — a well-scoped, realistic weekend project that demonstrates the core patterns behind most internal AI tools.

from slack_bolt import App
import anthropic

app = App(token="xoxb-your-bot-token", signing_secret="your-signing-secret")
claude = anthropic.Anthropic(api_key="your-api-key")

@app.event("app_mention")
def handle_mention(event, say):
    user_question = event["text"]

    response = claude.messages.create(
        model="claude-sonnet-5",
        max_tokens=500,
        system="You are a helpful assistant for the engineering team. "
               "Answer questions about our internal tools and processes concisely.",
        messages=[{"role": "user", "content": user_question}],
    )

    say(response.content[0].text, thread_ts=event["ts"])  # reply in thread

if __name__ == "__main__":
    app.start(port=3000)

What Makes This Genuinely Useful, Not Just a Toy

  • Grounding with internal knowledge — connect it to your actual internal wiki or documentation via RAG, so it answers based on your genuinely real, current information, not just generic knowledge
  • Thread awareness — pulling in the actual full thread’s context so follow-up questions genuinely work naturally, not just isolated single messages
  • Clear, honest scope boundaries — explicitly telling the bot (and genuinely, your users) what it can’t reliably help with, rather than letting it confidently attempt literally everything asked of it

This exact same core pattern — event trigger, retrieve relevant context, call an LLM, respond — genuinely underlies most internal AI tools regardless of the specific platform (Slack, Teams, a custom internal web app); the Slack-specific parts are really just the surrounding event handling and authentication plumbing.