Hey, I hope you guys enjoy my Streamlit Whatsapp Analyser!

So, I’m Akira, a computer engineer who recently had a dropoff in my coding output due to… well, covid-based issues, but even still, wanted to get back in the scheme of things, so I decided to build a pretty quick and dirty app that takes in as input the exported “.txt” file you can get from Whatsapp and it gives you a set of different indicators such as:

  • When you’ve talked to your friends the most
  • Who takes the longest to reply and how that has evolved through time
  • How long your conversations last and how that changed recently

I hope you guys enjoy it! This was loads of fun to make, and, if I’ve made any mistakes, I’d love some feedback since this was my first ever Streamlit App

Oh and it’s deployed on Heroku and Streamlit-sharing, if you guys would like to check it out:
St-share: Streamlit Sharing
Heroku: Heroku App

8 Likes

I love the idea (and that Gif! :heart_eyes:!) - Well done @akiragondo

If I may suggest one thing, it would be to allow users to try a sample file (with dummy and anonymised data) so they can see what your app is capable of! :slight_smile:

Best, :balloon:
Charly

1 Like

Thank you so much, I am really happy you liked it!

Aso, the sample file’s a brilliant idea, I’ll put that to effect right away!

All the best,

  • Akira
1 Like

Sounds great! Keep us posted Akira! :hugs:

Charly

Hey there again, Charly,

I’ve added a sample file button and a little customization to the footer, you can check it out now through those same links above, thank you for your help!

All the best,

  • Akira
1 Like

That’s brilliant! Thanks Akira!

1 Like

Hey there, Charly!

Your previous advice of putting in a sample file donwload button was so extremely helpful, if I may ask, is there anything you think would be interesting to add to the app’s design?

Thanks a lot!
Akira

1 Like

You’re welcome!

I’ll retry the app and have a think about what could be added

Best,
Charly

1 Like

Just want to ask, how did you create the gif (I guess it is a gif)?

1 Like

Very nice idea, thanks for sharing!

Unfortunately your WhatsApp export format seems to be different from mine, so your parser does not work for me (“Whoops — something went wrong! An error has been logged.”). Maybe it is because I am using the german/iOS version of WhatsApp? My exported data looks like:

[07.02.14, 15:20:34] ‎Max hat den Betreff zu “heute oder morgen” geändert.
[07.02.14, 15:21:31] ‎Max wurde hinzugefügt.
[07.02.14, 15:21:31] ‎Linda wurde hinzugefügt.
[07.02.14, 15:21:31] ‎Timo wurde hinzugefügt.
[07.02.14, 15:20:52] Max: So jetzt mal Butter bei die Fische. Heute oder morgen?
[07.02.14, 15:20:55] Timo: Ja das wäre ne wichtige Frage
...
1 Like

Yes! well, not a gif as in the image format, but it’s a Lottie animation, which basically does the same job but with less overhead (and you can use it directly through a web URL).
I would suggest you take a look at the st_lottie component from Streamlit and at the https://lottiefiles.com/, which contains a pretty large selection of those animations you can use with some attribution.

Hope I could be of some help!
Akira

Oh! yes, so, the idea was for it to mostly support only english whatsapp exports in order to narrow the scope of the project (because for some reason whatsapp exports in wildly different formats depending on the language it’s in), but I will work on making it be able to parse the messages from the German version too!

I hope it can get you some interesting insights (I like average reply times the best)
Akira

Hey! I’ve made some changes to the source code, It should work with your exports now! Thanks for sending the example export too, it should now work (Though I haven’t properly tested with group chats as much so tell me if you find anything!)

All the best
Akira

Hi @akiragondo, thanks for the effort! There still seem to be some issues though.

  • On the streamlit share page, I get the same error as before.
  • On Heroku, I get the error
File "/app/.heroku/python/lib/python3.9/site-packages/streamlit/script_runner.py", line 350, in _run_script
    exec(code, module.__dict__)
File "/app/main_page.py", line 118, in <module>
    df = get_df_from_data(content)
File "/app/data_utils.py", line 67, in get_df_from_data
    preprocessed = preprocess_df(df)
File "/app/data_utils.py", line 14, in preprocess_df
    conv_codes, conv_changes = cluster_into_conversations(df)
File "/app/data_utils.py", line 74, in cluster_into_conversations
    conv_delta[0] = 0

I had a quick look at your code and it seems that replacing the new line separator \\n with \n did the job.

def create_df_from_raw_file(raw_file_content):
    rows = raw_file_content.split('\n')

Another minor issue I noticed is that your regex catches strange Subjects/“senders” of messages, which might be relevant with the group chat only. Here are some of them:

Subject: Linda left the group.
Subject: ‎Max changed the topic to “Party Group”.

In my local playground I removed the Subjects based on a minimum threshold of messages to be sent. Here is a code example:

MIN_MSGS_SENT = 5
df_per_subject = df['Subject'].value_counts()

accepted_senders = df_per_subject[df_per_subject > 5].index

df_sel = df.query('Subject in @accepted_senders')

Maybe consider implementing something like that too :slight_smile:

1 Like

Hello! @tschmelzer, thank you so much for the suggestions!

I apologize for it, but it seemed like I needed to reboot my app on streamlit sharing, I haven’t tested it fully with large group chats, but I made a couple of different changes, including:

  • An improved regex line by line validator (so as to not catch group status messages like the ones you sent me)
  • Started using the readlines function instead of trying to split the rows manualy, which might work better usually, except maybe for windows phones

Thank you so much for the suggestions too! I’ll keep them in mind! In case the regex doesn’t fix the subjects issues, I’ll merge in the minimum message threshold you suggested

Thank you so much again for help!
Akira

Hi @akiragondo !

Thanks for the quick fixes, for me it works like a charm now :ok_hand:.

I just realized that you implemented a multiselector for the senders to be included into the analysis, so the minimum messages might be redundant.

All the best,
Timon

1 Like

Hello, @tschmelzer!

It was extremely useful to have an example export from the German/iOS version of WhatsApp, which really sped up the whole process, so, sincerely, thank you for bringing some of these issues to my attention and helping me walk through them!

I see you have posted an issue in my GitHub page, I will work on them as soon as I can, and thank you so much for donating your time for my project!

All the best,
Akira

1 Like

Cool app. Obviously inspired during your Covid issues. Glad to hear you’re back in the swing of things!

Happy Streamliting.

1 Like