ChatGPT Made Custom Emojis for Slack
Introduction
Hello. I am Koike, a data engineer in the Analytics Group. Slack is incredibly convenient, isn’t it? You might be wondering, “What’s this guy talking about all of a sudden?” But don't worry. It’s undeniable that Slack is a very useful tool. Among its features, I believe that emoji reactions are the most useful by far. But first, do you know what an emoji reaction is? Let me explain it in a bit more detail. Take a look at this image: This is something I posted in my personal times-channel. If you look at the area circled in white, you’ll notice small bubble-like icons. These are what we call emoji reactions. Next to the "🥲" emoji, there’s a "1," which meaning that one person reacted with that "🥲" emoji. The more reactions there are, the happier it makes me! There is also another emoji called donmai (meaning “don’t worry!”) This isn’t a default Slack emoji, but rather a custom emoji[1] added by a user. This time, I’ll be adding custom emojis with the help of ChatGPT.
Background
Let me explain why I wanted to add custom emojis in the first place. Our Analysis Group is split across three locations: Tokyo, Nagoya, and Osaka. This means some of us are working fully remotely at all times. Since offline communication does happen occasionally in each location, information gaps may be even more pronounced compared to a fully remote setup. To help bridge this gap, I thought we should focus more on using the text communication tool that is Slack. And that’s how I came up with the idea of adding custom emojis as a solution.
Creating custom Slack emojis
Now let's dive into adding custom emojis. Here’s how I plan to proceed:
- Count the number of times each emoji has been used in reactions
- Group the emojis collected in step 1 by the emotions they represent
- Use ChatGPT to generate words based on the groups created in step 2.
- Select the words generated in step 3, create images using an emoji creation tool, and register them on Slack.
Counting the number of times emojis are used
When it comes to adding custom emojis, it’s hard to know what exactly to add right away. So, I decided to start by researching what kinds of emojis are already being used regularly. Specifically, I’ll narrow down the channels and time period, and then examine the emoji reactions and how often they were used in posts to identify trends.
First, I created a Slack app, set the permissions as shown below (the permissions might be a bit excessive since I added whatever seemed necessary), and issued a token.
Next, I called the app from Python and performed the aggregation as follows:
import datetime
import pprint
import time
import yaml
from slack_sdk.web import WebClient
def main():
get_and_save_messages()
reaction_counts = get_reaction_counts()
pprint.pprint(sorted(reaction_counts.items(), key=lambda x: x[1], reverse=True))
def get_and_save_messages():
SLACK_API_TOKEN = "SLACK_API_TOKEN"
client = WebClient(token=SLACK_API_TOKEN)
target_channel_id_to_name = {
"id0": "#name0",
"id1": "#name1",
"id2": "#name2",
"id3": "#name3",
"id4": "#name4",
}
unix_times = get_unix_times()
messages = get_messages_in_channels(client, list(target_channel_id_to_name.keys()), unix_times)
with open("messages.yaml", "w") as f:
yaml.dump(messages, f, allow_unicode=True)
def get_messages_in_channels(client, channel_ids, unix_times):
merged_messages = []
for channel_id in channel_ids:
for unix_time_pair in unix_times:
merged_messages += client.conversations_history(
channel=channel_id,
include_all_metadata=False,
latest=str(unix_time_pair[0]),
limit=100000,
oldest=str(unix_time_pair[1])
)["messages"]
return merged_messages
def get_unix_times():
unix_times = []
today = datetime.date.today()
start = 1
end = 15
for _ in range(24):
start_date = today - datetime.timedelta(days=start)
end_date = today - datetime.timedelta(days=end)
start_unixtime = int(time.mktime(start_date.timetuple()))
end_unixtime = int(time.mktime(end_date.timetuple()))
unix_times.append((start_unixtime, end_unixtime))
start = end + 1
end = start + 14
return unix_times
def get_reaction_counts():
with open("messages.yaml", "r") as f:
messages = yaml.safe_load(f)
reaction_counts = dict()
for message in messages:
if "reactions" in message:
for reaction in message["reactions"]:
reaction_counts[reaction["name"]] = reaction_counts.get(reaction["name"], 0) + reaction["count"]
return reaction_counts
if __name__ == "__main__":
main()
Let me briefly explain the source code. In main()
, functions for each process are called. get_save_and_messages()
is a function that retrieves messages from Slack and saves them to a file. Note that SLACK_API_TOKEN
and target_channel_id_to_name
are hidden. If there are too many messages, they may not be retrieved all at once. To handle this, get_unix_times()
divides the period into smaller parts and returns a list, allowing the messages to be retrieved in smaller batches. Once the messages are retrieved, the function get_reaction_counts()
counts the number of emoji reactions. After that, the results are sorted by frequency and displayed.
Here is an example of the execution results: For example, ('man-gesturing-ok', 248)
means that the man-gesturing-ok
emoji was used 248 times as a reaction. The results include not only default emojis, but also custom ones and even emojis created by external users [2].
('man-gesturing-ok', 248),
('eyes', 248),
('arigatougozai', 199),
('understood', 64),
('+1', 49),
('thinking_face', 43),
('yorosikuonegaisimasu', 26),
('arigatougozaimasu', 17),
('tada', 15),
('nice', 14),
('arigato', 13),
('do_ne', 13),
('man-gesturing-no', 11),
('scream', 10),
('kakuninshimasu', 10),
('acknowledged2', 9),
('woman-bowing', 9),
('sob', 8),
('ok', 8),
('faito', 8),
('kami_bl', 7),
('done_hiragana', 7),
('desune', 7),
('naruhodo', 7),
('ok_hand', 7),
('sugoi', 7),
('tasukaru', 7),
('pray_mochimochi', 7),
('done-payment', 6),
('hai-', 6),
('nanto', 6),
('yokata', 6),
('mumondai', 6),
('tashi-crab', 5),
('muscle', 5),
('oh', 5),
('sasuga2', 5),
('uoooo', 5),
Emoji grouping
The resolution of the collected data is still low, so I will group the emojis by type of emotional expression to better understand their characteristics. While, I came across emotion classifications developed by psychologists, I found them too detailed and not well suited for this purpose. So I came up with my own method of grouping.
I propose that the structure could be divided into two main categories: actions for reporting, communicating, and consulting, and actions for expressing emotions. These can then be further subdivided for clarity. Here is the breakdown:
- Reporting, Communicating, and Consulting
- Reporting
- Checking
- Requesting
- Emotional Expressions
- Empathy
- Praise
- Gratitude
- Support
- Comfort
- Others
Let's apply this classification to the results from the earlier aggregation.
If you've looked closely, you may have noticed that for most of the emojis that didn’t clearly fit into any category, I sorted them based on intuition... 🤫 However, I believe the groupings I've come up with feel reasonably appropriate.
**Emoji generation using ChatGPT **
After grouping the emojis, the next step is to generate custom emojis for each emotional category. As a method, I’ll be using the popular ChatGPT. I used the GPT-4 model without plugins or web browsing features. Here’s the prompt I used:
I want to create custom emojis for Slack. Please provide 10 suggestions for each of the following categories:
Also, please try to keep them between 4 to 6 characters, using either hiragana, katakana, or kanji.
- Show empathy for the person who sent the message (e.g. :indeed:, :That's true:)
- Something to compliment the person who sent you the message (e.g. :Amazing:, :God:, :Great:)
- Something to show appreciation to the person who sent you a message (e.g. :Thanks:,:Appreciated:)
- Something to encourage the person who sent you the message (e.g.: :Fight:,:Woohoo:)
- Something to comfort the person who sent you the message (e.g. :Oh:,:Wow:)
Here are the results:
Custom emoji suggestions. I tried to keep each one within 4-6 characters using hiragana, katakana, or kanji.
Something that shows empathy for the person who sent you the message:
:I know: (wakaru yo)
:I agree: (doukan)
:Makes sense: (nattoku)
:Yep: (un un)
:That's it: (sore sore)
:I want to say: (iitai)
:Empathy: (kyoukan)
:I feel you: (kanjiru)
:You're right: (gomottomo)
:Thoughtfulness: (omoiyari)
Something to compliment the person who sent you the message:
:Amazing: (sugoi ne)
:Genius: (tensai)
:Incredible: (sugoi)
:Cool: (kakkoii)
:Lovely: (suteki)
:Beautiful: (utsukushii)
:Perfect: (kanpeki)
:I respect you: (sonkei)
:Praise: (shousan)
:You’re shining: (kagayaiteru)
Something to show appreciation to the person who sent you the message:
:Thank you: (arigatou)
:Gratitude: (kansha)
:I’m grateful: (kansha shiteru)
:Thanks: (arigatou ne)
:Thanks a lot: (arigatou-)
:You saved me: (tasukatta)
:Grateful feelings: (kansha no kimochi)
:Repay your kindness: (ongaeshi)
:Appreciation: (orei)
:I’m moved: (kangeki)
Something to encourage the person who sent you the message:
:Do your best: (ganbatte)
:Fight: (faito)
:Hang in there: (ganbare)
:I’m cheering for you: (ouen suru)
:I’ll be your strength: (chikara ni naru)
:Let's do our best together: (issho ni ganbarou)
:Let’s keep going: (ganbarimashou)
:Sending you cheers: (eeru wo okuru)
:Wishing you success: (seikou wo Inoru)
:Be confident: (jishin wo motte)
Something to comfort the person who sent you the message:
:It’s okay: (daijoubu)
:Hang in there: (ganbare)
:Don’t worry about it: (ki ni shinaide)
:You did your best: (ganbatta ne)
:It's tough: (tsurai ne)
:That's tough: (tsurai yo ne)
:Tomorrow is a new day: (ashita wa atarashii hi)
:Don't feel down: (ochikomanaide)
:Stay positive: (maemuki ni)
:You’re doing great: (ganbatteru ne)
Some of these may feel unnatural for use on Slack, but overall, they seem pretty good.
Emoji selection and Slack registration
Next, I'll select the most useful ones from the emojis generated by ChatGPT, while removing any that are already registered in the Slack workspace.
- Empathy
- :I understand:
- :I agree:
- :You have a point:
- Praise
- :That’s amazing:
- Gratitude
- :I am touched:
- Support
- Comfort
- :Don’t worry:
This is what it turned out like. Finally, I’ll use an emoji creation tool [^3] to turn these into images and register them on Slack.
Ah, what a great view!
Conclusion
What do you think? While this may not instantly enhance communication on Slack, taking the initiative to actively use the new emojis and encourage their adoption across the organization will be key. This time, we’ve added custom emojis spanning various emotional expression categories, but focusing on creating emojis to fill specific gaps could also be effective. I encourage you to try them out in your organization’s Slack space!
関連記事 | Related Posts
We are hiring!
【データサイエンティスト(リーダークラス)】分析G/東京・名古屋
分析グループについてKINTOにおいて開発系部門発足時から設置されているチームであり、それほど経営としても注力しているポジションです。決まっていること、分かっていることの方が少ないぐらいですので、常に「なぜ」を考えながら、未知を楽しめるメンバーが集まっております。
【データエンジニア】分析G/名古屋・大阪
分析グループについてKINTOにおいて開発系部門発足時から設置されているチームであり、それほど経営としても注力しているポジションです。決まっていること、分かっていることの方が少ないぐらいですので、常に「なぜ」を考えながら、未知を楽しめるメンバーが集まっております。