Integration with Telegram Bot

Prerequisite

Your bot token should looks like:

4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc

Connect your Memos to Telegram Bot

Once you have prepared your bot, you can now connect Memos to your bot.

  1. Sign in to your Memos using the admin account.
  2. Click the Settings button on the sidebar to open Settings dialog.
  3. Switch to System tab in the Admin section.
  4. Copy and paste your bot token into Telegram Token field, then click Save.

Now, the Telegram bot is connected to your Memos.

Bind Memos user to Telegram user

After connecting your Telegram bot to Memos, you can send messages to the bot.

You will receive a message like this:

user-id-message

The message contains your user ID in Telegram. Make sure to copy it.

Follow these steps to set it as your Memos user:

  1. Sign in to your Memos.
  2. Click on Settings button on the sidebar to open Settings dialog.
  3. Switch to Preferences tab in Basic section.
  4. Paste your userid into Telegram UserID field, then click Save.

You can now send messages to the Telegram bot, and they will be saved in your Memos!

message-saved

We currently support two types of messages from the Telegram bot:

  • Text message: The message will be the content of memo, and Markdown format is supported.

  • Photo message: The photo will be saved as resources into memo. And the caption of photo will be content of memo.

Use a Proxy for Telegram API?

Memos support connect to Telegram API with a proxy.

Assuming you have a proxy server running on PROXY_URL, you should setup it to make sure:

  • Any request on PROXY_URL/bot<token> forward to https://api.telegram.org/bot<token>
  • Any request on PROXY_URL/file/bot<token> forward to https://api.telegram.org/file/bot<token>

You can also just forward all request to PROXY_URL directly to https://api.telegram.org to make it simple.

If that's OK, just config the bot token of your Memos like below:

http://proxy.test.com:8081/somepath/bot<token>

Replace <token> with the original bot token from Telegram's @BotFather.

Can I Use Webhook instead of API Proxy ?

NO.

In addition to receiving updates from Telegram, many features require visit Telegram's API directly, such as downloading images and sending replies. Therefore, the environment in which Memos running on must be able to Directly access Telegram. If for some special reasons it is not possible to access it directly, then a Proxy API is a necessity. On this basis, providing additional support for Webhooks is not too necessary, at least it doesn't have much significance in terms of resolving the accessibility of Telegram.

What's next?

The Telegram bot is a powerful tool, and we have only implemented a few features so far. We plan to add more features in the future, including:

  • Commands for the Telegram bot to perform special actions.
  • Sending notifications through the Telegram bot.
  • And more...

We welcome any pull requests. Enjoy using Memos!