尝试使用 Bot Framework 在 Telegram 中发送消息时出错
Error trying to send message in Telegram with Bot Framework
var connector = new ConnectorClient();
List<ChannelAccount> participants = new List<ChannelAccount>();
var tBot = new ChannelAccount
{
ChannelId = "telegram", Address = "9digit", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot"
};
participants.Add(tBot);
var tUser = new ChannelAccount
{
ChannelId = "telegram", Address = "9digit", IsBot = false, Id = "dsalodki", Name = "dsalodki"
};
participants.Add(tUser);
Message message = new Message
{
From = tBot,
To = tUser,
Participants = participants.ToArray(),
Text = "Hey, what's up everyone?",
Language = "en"
};
var obj = connector.Messages.SendMessage(message);
Unhandled Exception: Microsoft.Rest.HttpOperationException: The bot ... does not match From:... To:...
怎么了?
Message.From.Address 字段需要包含机器人 ID,如下所示:
var tBot = new ChannelAccount
{
ChannelId = "telegram", Address = "salodkid_bot", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot"
};
var connector = new ConnectorClient();
List<ChannelAccount> participants = new List<ChannelAccount>();
var tBot = new ChannelAccount
{
ChannelId = "telegram", Address = "9digit", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot"
};
participants.Add(tBot);
var tUser = new ChannelAccount
{
ChannelId = "telegram", Address = "9digit", IsBot = false, Id = "dsalodki", Name = "dsalodki"
};
participants.Add(tUser);
Message message = new Message
{
From = tBot,
To = tUser,
Participants = participants.ToArray(),
Text = "Hey, what's up everyone?",
Language = "en"
};
var obj = connector.Messages.SendMessage(message);
Unhandled Exception: Microsoft.Rest.HttpOperationException: The bot ... does not match From:... To:...
怎么了?
Message.From.Address 字段需要包含机器人 ID,如下所示:
var tBot = new ChannelAccount
{
ChannelId = "telegram", Address = "salodkid_bot", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot"
};