Telegram 节点常见问题#
¥Telegram node common issues
以下是 Telegram 节点 的一些常见错误和问题,以及解决或故障排除步骤。
¥Here are some common errors and issues with the Telegram node and steps to resolve or troubleshoot them.
向 Telegram 通道添加机器人#
¥Add a bot to a Telegram channel
要让机器人向通道发送消息,你必须将机器人添加到该通道。如果你尚未将机器人添加到通道,你将看到类似如下的错误描述:Error: Forbidden: bot is not a participant of the channel。
¥For a bot to send a message to a channel, you must add the bot to the channel. If you haven't added the bot to the channel, you'll see an error with a description like:
Error: Forbidden: bot is not a participant of the channel.
要向通道添加机器人:
¥To add a bot to a channel:
- 在 Telegram 应用中,访问目标通道并选择通道名称。
¥In the Telegram app, access the target channel and select the channel name. 2. 将通道名称标记为公共通道。
¥Label the channel name as public channel. 3. 选择“管理员”>“添加管理员”。
¥Select Administrators > Add Admin. 4. 搜索机器人的用户名并选择它。
¥Search for the bot's username and select it. 5. 选择右上角的勾选标记以将机器人添加到通道。
¥Select the checkmark on the top-right corner to add the bot to the channel.
获取聊天 ID#
¥Get the Chat ID
你只能在公共通道上使用 @channelusername。要与 Telegram 群组互动,你需要该群组的聊天 ID。
¥You can only use @channelusername on public channels. To interact with a Telegram group, you need that group's Chat ID.
获取 ID 有三种方法:
¥There are three ways to get that ID:
- 从 Telegram 触发器获取:在工作流中使用 Telegram 触发器 节点获取聊天 ID。此节点可以根据不同的事件触发,并在成功执行后返回聊天 ID。
¥From the Telegram Trigger: Use the Telegram Trigger node in your workflow to get a Chat ID. This node can trigger on different events and returns a Chat ID on successful execution.
2. 从 Web 浏览器获取:在 Web 浏览器中打开 Telegram 并打开群聊。群组聊天 ID 是字母 "g." 后面的数字序列。在 n8n 中输入群组聊天 ID 时,请在 ID 前加上 - 前缀。
¥From your web browser: Open Telegram in a web browser and open the group chat. The group's Chat ID is the series of digits behind the letter "g." Prefix your group Chat ID with a - when you enter it in n8n.
3. 邀请 Telegram 用户 @RawDataBot 加入群组:添加后,机器人会输出一个包含 chat 对象的 JSON 文件。该对象的 id 是群组聊天 ID。然后从你的组中移除 RawDataBot。
¥Invite Telegram's @RawDataBot to the group: Once you add it, the bot outputs a JSON file that includes a chat object. The id for that object is the group Chat ID. Then remove the RawDataBot from your group.
每秒发送超过 30 条消息#
¥Send more than 30 messages per second
Telegram API 的 limitation 限制为每秒仅发送 30 条消息。请按照以下步骤发送超过 30 条消息:
¥The Telegram API has a limitation of sending only 30 messages per second. Follow these steps to send more than 30 messages:
- 循环遍历项目节点:使用 循环处理项目 节点从数据库中获取最多 30 个聊天 ID。
¥Loop Over Items node: Use the Loop Over Items node to get at most 30 chat IDs from your database. 2. Telegram 节点:将 Telegram 节点连接到“循环遍历项目”节点。使用 Expression Editor 从 Loop Over Items 节点中选择聊天 ID。
¥Telegram node: Connect the Telegram node with the Loop Over Items node. Use the Expression Editor to select the Chat IDs from the Loop Over Items node. 3. 代码节点:将 代码 节点连接到 Telegram 节点。使用代码节点在获取下一批聊天 ID 之前等待几秒钟。将此节点与“循环遍历项目”节点连接。
¥Code node: Connect the Code node with the Telegram node. Use the Code node to wait for a few seconds before fetching the next batch of chat IDs. Connect this node with the Loop Over Items node.
你还可以使用此 workflow。
¥You can also use this workflow.
移除已发送消息中的 n8n 属性#
¥Remove the n8n attribution from sent messages
如果你使用节点连接到 发送 Telegram 消息,则邮件末尾会自动附加 n8n 属性:
¥If you're using the node to send Telegram messages, the message automatically gets an n8n attribution appended to the end:
此消息由 n8n 自动发送。
¥This message was sent automatically with n8n
移除此属性:
¥To remove this attribution:
- 在节点的“附加字段”部分,选择“添加字段”。
¥In the node's Additional Fields section, select Add Field. 2. 选择“追加 n8n 归属”。
¥Select Append n8n attribution. 3. 关闭开关。
¥Turn the toggle off.
有关更多信息,请参阅 发送消息附加字段。
¥Refer to Send Message additional fields for more information.