gpt4 book ai didi

telegram - 如何通过网站 Telegram 向登录的用户发送消息?

转载 作者:行者123 更新时间:2023-12-05 02:16:43 31 4
gpt4 key购买 nike

网站telegram如何给登录用户发送消息?

Telegram Login for Websites

Telegram bots are a powerful communication tool, but until today they couldn't start a conversation. Even if you wanted them to reach out to you, you had to chat them up first.

Bot API 3.6

Added the new field connected_website to Message. The bot will receive a message with this field in a private chat when a user logs in on the bot's connected website using the Login Widget and allows sending messages from your bot.

登录用户后,我的机器人无法使用 user_id 发送消息,即使 OnMessage 事件也未触发。

如何通过机器人发起对话?

感谢。

最佳答案

你在这里自己回答了你的问题:

Added the new field connected_website to Message. The bot will receive a message with this field in a private chat when a user logs in on the bot's connected website using the Login Widget and allows sending messages from your bot.

更多说明:用户使用 Telegram 登录小部件登录后,您应该等待更新事件(假设您正在为 Telegram Bot 使用 Webhook 方法)。更新正文应该是这样的:

{
"update_id": 290285,
"message": {
"message_id": 12,
"from": {
"id": 117854,
"is_bot": false,
"first_name": "",
"last_name": "",
"language_code": "fa"
},
"date": 1549829158,
"chat": {
"id": "you need this to start conversation",
"type": "private",
"first_name": "user_firstname",
"last_name": "user_last name"
},
"connected_website": "the domain mapped to your bot"
}

从填写的“connected_website”可以看出这是第一次登录的用户并保存聊天ID以在以后开始下一次对话。PS:我想知道为什么在 Telegram 中没有关于此的文档,或者至少我没有找到任何东西。

关于telegram - 如何通过网站 Telegram 向登录的用户发送消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49073980/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com