[APP][Pro] Telegram

Frequently Asked Questions (FAQs) - Homey Pro Telegram Bot App

Q1: I’m encountering a “Bad Request: can’t parse entities” error with the message, “Character ‘(’ is reserved and must be escaped with the preceding ‘\’”. What should I do?

Answer

A: This error indicates an issue with parsing entities, specifically with characters like ‘(’. To resolve this, make sure you escape non-Markdown characters properly. If your variables or tokens, especially those from Homey Flows, contain special characters, switch to HTML or use the Better Logic Library (BLL) to escape them.

Q2: How can I escape non-Markdown characters in my variables?

Answer

A: If your variables contain special characters like . , * / & % $, and Telegram can’t differentiate them from Markdown special characters, you need to escape them. There are two recommended ways to address this issue:

  • Option 1: Use HTML Markdown: Convert your message to HTML format, where special characters won’t conflict with Markdown. Telegram supports HTML formatting.
  • Option 2: Utilize Better Logic Library (BLL): Implement a custom function for escaping special characters using BLL. Here’s an example function you can use:
function escapeRegex(string) {
   return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
}

Then, use it in your message like this: {[escapeRegex(variable)]}.

By following either of these options, you can ensure proper handling of special characters in your variables, resolving the parsing issue.

Q3: Why am I getting an error related to special characters in my variables, and how does the Better Logic Library (BLL) help?

Answer

A: The error occurs because Telegram can’t distinguish between Markdown special characters and non-Markdown characters in your variables. Since you are using special characters like . , * / & % $, you need to escape them. BLL provides a solution by offering a custom function, such as the provided escapeRegex function, to escape these characters. By incorporating this function into your flow, you ensure proper handling of variables with special characters, eliminating parsing errors.

Q4: How does markdown work (HTML vs. MarkdownV2)?

Answer

A: For detailed information on how markdown works, particularly the differences between HTML and MarkdownV2 in the context of the Homey Pro Telegram Bot App, please refer to the community discussion thread here.

Q5: How do I set up the Homey Pro Telegram Bot App?

Answer

A: Follow these steps to set up the Homey Pro Telegram Bot App:

  1. Install the app on your smart home hub.
  2. Create a Telegram bot by searching for “@Botfather” in the Telegram search bar and selecting it.
  3. Start “@Botfather” by clicking “Start” or sending the /newbot command to create a new bot.
  4. Enter the token provided by Botfather in the app settings.
  5. Set a secure password in the app settings.
  6. Start the bot by sending /start yourPassword in Telegram (replace yourPassword with your configured password).
  7. Share the bot with others by searching for it in Telegram or sharing its profile link.

Enjoy controlling your smart home from Telegram!

Q6: How can I support the development of the Homey Pro Telegram Bot App?

Answer

A: There are two ways you can support the app:

  1. Contribute via GitHub: If you have coding skills or want to contribute in other ways, you can visit the GitHub repository at GitHub - spkesDE/com.spkes.telegramNotifications. Feel free to contribute by submitting bug reports, feature requests, or even code improvements.
  2. Make a Donation: If you prefer to support the developer financially, you can send a donation. Visit the community thread here to find information on how to make a donation. Your contributions help in the continuous improvement and maintenance of the Homey Pro Telegram Bot App.

Your support, whether through contributions on GitHub or donations, is highly appreciated and contributes to the ongoing development of the app.

Q7: How can I enable Markdown?

Answer

A: In the app settings is a option to enable MarkdownV2 or HTML Markdown.

Q8: For what is the password in the Bot Settings?

Answer

A: The password is used for the /start command. Only users who know the password can register the bot to their Telegram channel. This ensures that unauthorized users cannot register the bot.

If a new user/chat should be registered, you have to use /start myPassword (of course, replace myPassword with your actual password).

Q9: I can send messages to a group but not receive them. What should I check?

Answer

A: If the bot is unable to read messages in a group:

  • Ensure /Setprivacy is disabled so the bot can read all messages without requiring an @mention .
  • Verify that the bot has the correct permissions to read and send messages in the group.

Q10: Do I need to reference the bot when sending messages in a group?

Answer

A: If /Setprivacy is enabled, the bot will only respond to messages that mention it using @BotUsername . Disabling /Setprivacy allows the bot to read all messages in the group.

Q11: There is no Chat/Topic in the settings?

Answer

A: You have to register the chat via the /start command. In a group, the bot has to be added, and the start command must reference the bot or /Setprivacy must be disabled.

1 Like