Feeding AI Models with Slack Data

How to build connections on teams by marrying Slack and generative AI

Taylor Wagner
Slalom Build
6 min readMar 28, 2024

--

Background

Every year around the beginning of Q3, Slalom Build kicks off a global hackathon competition to take technological possibilities from the novel to the relevant for our clients and communities. The theme for 2023 was none other than Generative Artificial Intelligence. The overarching mission of the 2023 Hackathon was essentially to answer the question:

How can we (as Builders) leverage GenAI to better serve our clients?

The competition in the hackathon is fierce every year, but there was an extra gust of wind under the wings of GenAI for 2023. Like a twenty-first-century space race, we were all defining the road map as we traveled on it when it came to GenAI. There were a few important factors that my team considered when developing our project’s objectives and architecture.

Hackathon Planning

One important factor to consider when working with generative AI models (in general) is that the model needs data to be able to produce. The models need to be prompted with information to provide the user with valuable results. So, where was our data going to be sourced from?

Another factor my team considered when determining what we were going to build for the competition was connection. It is no secret that people have become isolated since the onset of the pandemic. Therefore we explored the possibility of: Could we use GenAI to help foster connection within our Slalom Build teams?

With these factors considered, my team’s objective became to build an app using ChatGPT’s capabilities that could provide opportunities for more connectivity and fun for teams that were meeting in person by creating games that met the interests of team members.

Of course, we could just ask ChatGPT to “create a game for seven coworkers to play in person,” but we wanted more. We wanted deeper and more meaningful connections. We wanted the games to be relevant and interesting to the game players.

My Hackathon team (BuildPlay) decided to leverage Slack channel data as the source for our model. Essentially, we wanted to feed our GenAI model data from the Slack channel to then let AI create user profiles and personalities. Based on those profiles and popular “themes” from topics discussed in the channel, GenAI would then create a relevant game for users to play and connect.

Spoiler alert: my team was a finalist in the top 16 of the competition!

At Slalom Build, we stand on the Situation-Behavior-Impact feedback model, so I will lean on that template to showcase the proof of concept piece that I built on my team to feed our GenAI model with data from Slack.

Situation

BuildPlay asked: “How can we leverage generative AI to create connection and fun for Builders?” And we answered this question by envisioning an application that uses public Slack channels to correlate ideas with individuals, while also capturing drivers, personalities, and running jokes amongst team members. Our approach centered on the power of chaining generative AI to transform public Slack data into meaningful moments of connection.

The creation of games would be facilitated by generative AI through a series of tagging, summarizing, and filtering requests. By transforming Slack data into personality profiles, we could employ them as contextual input for game development.

Image provided by the Author

Thus the situation at hand became—how do we feed the data from public Slack channels into our AI model?

Please note: there is additional architecture for the BuildPlay application beyond this point highlighted so far; however, I am only mentioning this first portion of the architecture for this article.

Behavior

I set out to build the proof of concept for the Slack data integration into our application by leaning into the Slack API, which is free. Once I was set up with a token for Slack’s API and discovered the conversations.history method, the rest was pretty smooth to set up and boiled down to one major function.

def extract_messages(channel_id):
try:
response = client.conversations_history(channel=channel_id)
messages = response['messages']
while response['has_more']:
response = client.conversations_history(
channel=channel_id,
cursor=response['response_metadata']['next_cursor']
)
messages.extend(response['messages'])
except SlackApiError as e:
print(f"Error retrieving messages: {e.response['error']}")
return []

extracted_messages = []
for i, message in enumerate(messages, start=1):
user_info = client.users_info(user=message['user'])
user_name = user_info['user']['real_name']

# Replace user IDs with real names in the message
tagged_users = re.findall(r'<@(.*?)>', message['text'])
for user_id in tagged_users:
user_info = client.users_info(user=user_id)
user_name = user_info['user']['real_name']
message['text'] = message['text'].replace(f'<@{user_id}>',
user_name)

timestamp = float(message['ts'])
dt_object = dt.fromtimestamp(timestamp)
formatted_datetime = dt_object.strftime('%Y-%m-%d %I:%M %p')

extracted_messages.append({
"id": i,
"person": user_name,
"datetime": formatted_datetime,
"message": message['text'],
"reactions": extract_reactions(message.get('reactions', [])),
"replies": message.get('reply_count', 0)
})
return extracted_messages

Within the extract_messages function, you will see that I had to do a little manipulation to the data for user name and date/time display; however, I was able to pull all the data necessary from Slack via the Slack API that the generative AI model would need for creating the personality profiles in our application.

Focusing at the end of the function is an extracted_messages.append() portion, which indicates that I pulled the following data from the public Slack channel messages:

  1. Name of the author of the message
  2. Date and time of message
  3. Message contents
  4. Information on the reactions to the message in the form of: emoji type and the number of reactions to said emoji
  5. Number of replies to a message

The data on the public Slack channel could now be fed into our generative AI model with a simple script to be run at any time, keeping the AI model up to date with the happenings on the Slack channel.

To get a deeper look into the contents of the script, you can take a look at the public repository for this POC here.

Impact

The impact that this script had on our application was to foster more personalization in the games of BuildPlay, as opposed to more generic, monotonous experiences.

For example, one team’s Slack channel discussed food a lot (because what team doesn’t?!); thus, generative AI proposed a game where game players had to draw pictures of the worst food they’ve ever eaten. Another game required players to divide into teams and debate whether green or red grapes were more tasty. These games could provide opportunities for much deeper connections and inspire more attentive participation than a random game of duck-duck-goose that the model would create on its own without “knowing” the team.

Generative AI is a fear-inducing topic for many people, especially those who work in technology. A common thought process and question during these times: is generative AI going to replace us and put people out of their jobs?

At Slalom Build, we believe generative artificial intelligence offers opportunities for new work—particularly for those who learn how to use it to grow and build, as exemplified by the theme of the 2023 Hackathon competition. And if you ask any member of BuildPlay—we believe GenAI also offers opportunities to connect!

Thank Yous

Thank you to the entire team dedicated to running the Hackathon at Slalom Build—your efforts cannot be easily replicated and it’s a labor of love that upskills our talents immeasurably!

Thank you to the BuildPlay team—Kim Adams, Srijaya Suresh, Zubair Khan, Jay Patel, and Sam McClanahan—it was a pleasure hacking with you all!

Resources

--

--