Migrating primary messenger apps
Ditching bad messengers like Telegram for the better
projectstelegramsignalmatrixelementmessaging
1256 Words
2025-05-09
I have to admit, that I am have been a long term Telegram user since beginning of 2015 - so for a little more than 10 years.
While the App has been criticized quite a lot due to political reasons and the milieu of people using it, it is also a great opportunity for development (of bots), useful features, great usability of the client application and much more.
All this is also possible because Telegram does not care much about E2EE (end-to-end encryption) in the majority of chats.
While E2EE was not that widely implemented back then, using a messenger without proper E2EE support nowadays is not a good situation.
I wanted to migrate away from Telegram for quite a while as solutions with more transparency and security exist which are not powered by tech giants, though migrating without losing the chat history seems generally impossible.
Regarding features of different messengers, a lot of reviews and comparisons already exist on the internet. The best comparison of messenger apps available is the messenger-matrix maintained by Kuketz-Blog.
From this I evaluated the following two candidates:
- Signal
- Matrix Ecosystem (aka Element or Element X)
Matrix rant 2025
The Matrix protocol and ecosystem has always been very interesting, as it tries to bridge different worlds of messengers together. It makes communication between XMPP, IRC, Telegram and Discord rooms possible, while also being federated, self-hosted and having E2EE (not between bridged rooms of course).
While I host a Synapse Matrix server for quite a while as well, this Ecosystem never made it convenient to search in old messages or transfer history from other chat clients (which indeed is a hard problem on E2EE large rooms). The new Element X client is indeed snappier through Sliding Sync, but does not have any functionality to search the content of messages. For some chats which are also somewhat used as a wiki and casually reference old messages, this is quite crucial.
Furthermore, the integration of voice call is not as good and does not work only with TURN but also requires LiveKit and special configuration. All in all, this includes a lot of complexity. Running synapse is not easily transferable to other home server implementations like dendrite and co, so this does not feel like a good step forwards as we also do not have any export format supported to ease the migration from or towards other messengers.
The bridges and puppeting is very nice, though it does not allow migrating both sides to matrix transparently. Furthermore, having a way to backfill the whole history of two participants is also not always supported.
In the future the messenger situation might change through the EU Digital Markets Act (DMA).
Future interoperability of messengers
Technical preparation is on the way through MLS/RFC9420 about which I heard a talk at the CCC two years ago. This might happen through the RCS already supported by iOS and Android, but I would not bet on it making the migration easier.
Therefore, we want to migrate away today.
So what is the best bet today?
So for my daily communications I have the requirements of E2EE, a searchable history, transfer of my messaging history as well as a good user interface. This is possible with latest versions of Signal.
A few months ago, Signal did not have a way to transfer past chat history to linked devices (e.g. laptops), which was not very good as I got a new laptop. However, this situation has changed now, and Signal asks if the linked device should have all messages transferred as well.
While many already use Signal, the open question now is how my history from Telegram can be transferred to Signal.
Transferring Telegram history to Signal
The very useful signalbackup-tools provide options to manipulate or edit an Android signal backup: https://github.com/bepaald/signalbackup-tools
This is quite interesting, as the basic backup structure of Signal is an encrypted SQLite database which holds all the information. As this information is not signed with by the sending key, one can not guarantee authenticity of messages if a backup is restored into latest Signal versions. Of course, this is required for our steps, as we manipulate the backup to insert the Telegram messages.
First we need the Backup of the Telegram data using Settings -> Advanced -> Export Telegram Data (bottom option)
in the Telegram Desktop client.
This takes 24 hours to be allowed to download this data, which is fine. Make sure to export as Machine-Readable data, which is read into the signalbackup-tools in the further steps.
Secondly, we require a Signal Backup, which can be obtained using Settings -> Chats -> Chat Backups (bottom option)
. Make sure to write down the backup passphrase and have your Signal account password at hands.
Both are required for restore.
As we retrieve the latest version of the tool at https://github.com/bepaald/signalbackup-tools, we can import the Telegram data into the signal backup using the following line:
./signalbackup-tools ./signal-2025-05-09-19-42-14.backup "00000 00000 00000 00000 00000 00000" --importtelegram ./Telegram_DataExport_2025-05-09/result.json -o signal-with-telegram.backup --jsonmarkread
This will probably always fail due to chats which can not be mapped from Telegram to Signal. So we need to investigate this mapping using:
./signalbackup-tools ./signal-2025-05-09-19-00-00.backup "00000 00000 00000 00000 00000 00000" --listrecipients
for the Signal contacts showing:
_id | display_name | e164 | blocked | hidden | has_avatar | type | registered | has_id | has_thread |
---|---|---|---|---|---|---|---|---|---|
23 | Alice Random | +4915789012345 | 0 | 0 | 1 | Individual | Yes | 1 | 0 |
1 | My Name | +4915789012345 | 0 | 0 | 0 | Individual | Yes | 1 | 1 |
And the following to show the list of contacts from Telegram:
./signalbackup-tools --listjsonchats ./Telegram_DataExport_2025-05-09/result.json
idx | id | name | type | message_count |
---|---|---|---|---|
0 | 987654321 | Alice Random | personal_chat | 136729 |
1 | 123456789 | Florian Maurer | saved_messages | 4907 |
Now we can check the mapping between these contacts initially done by the tool using:
./signalbackup-tools ./signal-2025-05-09-19-00-00.backup "00000 00000 00000 00000 00000 00000" --jsonshowcontactmap ./Telegram_DataExport_2025-05-09/result.json
And craft the actual conversion to only take the most relevant chats with you using selectjsonchats
.
The final command did look somewhat like this for me:
./signalbackup-tools ./signal-2025-05-09-19-00-00.backup "00000 00000 00000 00000 00000 00000" --importtelegram ./Telegram_DataExport_2025-05-09/result.json -o signal-with-telegram.backup --jsonmarkread --selectjsonchats 0,1,2,3,4,5,7,8,26,42,11 --mapjsoncontacts User1=6797,User2=6835,User3=337,User4=391
Let me explain.
--selectjsonchats
takes the list of Telegram chats here. This is theidx
column in the--listjsonchats
command--mapjsoncontacts
is a mapping between thename
column of the telegram output and the_id
of the Signal chat
It is not needed to set --preventjsonmapping
. Further output can be enabled with the --verbose
flag.
Before transferring the crafted backup back to your phone to restore it, we can make sure that everything works as intended using the exporthtml
flag:
./signalbackup-tools ./output.backup "00000 00000 00000 00000 00000 00000" --exporthtml htmlout
and investigate the htmlout
folder to make sure that all chats are merged as expected.
Finally, we can restore the data on our Android phone by reinstalling Signal or deleting all App data.
Closing words
This means, that we can randomly manipulate a Signal backup, to integrate additional messages. When we delete all data from a desktop client before linking it, it can now transfer all data to the desktop client as well during linking - including the Telegram message of the last 10 years.
I really hope that this is helpful for other people as well. Of course, this is quite technical, but still, many people using Telegram since the early days came there from the tech bubble and probably struggle to fully migrate for similar reasons.
I am very glad to have made this move, though I already miss some features of the Telegram client, like the fast emoji lookup using a colon followed by an emoji word… 😊