Basic Knowledge
November 5, 2024

Building GptPanda: Integrating ChatGPT into Slack at Scale

By Sarah Chen, Lead Engineer at GptPanda

The Problem

As a backend engineer who lived in Slack for years, I noticed a significant gap in the ecosystem. While we had plenty of external AI tools, the context-switching required to use them was killing productivity. The solution seemed obvious: bring AI directly into where teams already work - Slack.

I started thinking about how powerful it would be to have an AI assistant that lived within Slack itself. An assistant that could handle tasks like answering questions, summarizing conversations, brainstorming, and organizing tasks—all without leaving the platform. That was the idea: to create an AI assistant so seamlessly integrated that it felt like a natural part of Slack conversations.

From Idea to Reality: Building the AI Assistant

The concept was simple: embed AI directly into Slack’s workspace. But making this idea a reality wasn’t as straightforward as it seemed. Integrating an advanced AI model like ChatGPT into Slack’s dynamic environment presented unique challenges.

First, the AI needed to follow fast-moving conversations that frequently shift topics. In Slack, discussions happen across multiple threads, and the assistant needs to be smart enough to remember the context of each one. This required building a contextual memory system, allowing the AI to track details and provide intelligent, timely responses based on what had already been discussed.

The Challenges: Making the Assistant Feel Natural

One of the toughest aspects of the project was making the AI feel like a natural part of Slack. Slack users often talk about multiple things at once, and the assistant needs to respond in a way that fits into the conversation, not disrupt it. It couldn’t deliver generic answers—it had to understand the flow, track ongoing threads, and deliver meaningful insights.

To solve this, we spent weeks creating a system that allowed the AI to handle multiple threads at the same time. It needed to follow the conversation, retain relevant information, and jump in when it could add value—whether answering a question, summarizing a thread, or contributing to brainstorming.

Overcoming Technical Hurdles: The Roadblocks We Faced

Performance was another major challenge. Slack users expect real-time responses, and any lag would make the AI more of a nuisance than a help. To manage this, we developed a batching system that optimized how the AI communicated with Slack’s API, allowing the assistant to handle unlimited requests quickly and smoothly.

One of the biggest hurdles was figuring out how to bypass Slack’s rate limits while maintaining top performance. Our lead engineer, Max, came up with a solution that bundled requests and processed them in bursts. This was one of the key breakthroughs that kept the assistant responsive, even with thousands of conversations happening simultaneously.

Introducing GptPanda: AI Assistant for Slack

Once the core functionality was built, it was time to bring the assistant to life with a name and identity. That’s when GptPanda was born—an AI assistant fully integrated into Slack, powered by ChatGPT. Our goal was to create more than just a tool; GptPanda had to be a productivity partner, deeply embedded into Slack so teams could work smarter without interruptions.

Today: A Solution Trusted by Thousands of Users

Since its launch, GptPanda has become a critical part of many teams’ workflows. Whether it’s helping brainstorm ideas, manage tasks, answer technical questions, or keep track of conversations, GptPanda is now used by thousands of users daily—all within Slack. It’s so well-integrated that it feels like a natural part of the platform.

Teams can start with a freemium plan that covers essential AI tasks or upgrade to the premium version for just $1 per user per month, unlocking features like contextual memory and unlimited requests.

Here’s a snippet of the code that powers GptPanda’s contextual memory system. This system helps GptPanda track multiple conversation threads across Slack, ensuring it delivers accurate, contextually aware responses:

```
async def join_all_public_channels(bot_token: str) -> None:
    headers = {"Authorization": f"Bearer {bot_token}"}
    async with httpx.AsyncClient() as client:
        response = await client.get(
            "https://slack.com/api/conversations.list",
            headers=headers,
            params={"types": "public_channel"},
        )
        result = response.json()
        channels = result.get("channels", [])
        tasks = []
        for channel in channels:
            async with async_session_maker() as session:
                task = asyncio.create_task(
                    join_slack_channel(session, channel["id"], channel["context_team_id"], bot_token),
                )
                tasks.append(task)

        tasks.append(
            asyncio.create_task(
                send_welcome_message(
                    channels_id=await get_team_members_from_workspace(bot_token, channels[0]["context_team_id"]),
                    bot_token=bot_token,
                    message_blocks=settings.private_welcome_message,
                ),
            ),
        )
        await asyncio.gather(*tasks)
```

To make the code more understandable, I’ve added links to Slack’s API documentation, where you can see the method used to add the bot to channels: Slack API conversations.join. This piece of code fetches a list of all channels from Slack’s API, allowing GptPanda to join public channels and keep track of ongoing conversations.

The Road Ahead: More Innovation to Come

Looking forward, I’m excited to keep evolving GptPanda. Building an AI assistant inside Slack has taught me that the hardest challenges often lead to the most innovative solutions. By focusing on solving real problems, we’ve created something that truly makes a difference for teams.

GptPanda isn’t just an AI tool—it’s your productivity partner. And this is only the beginning.

Get API Key