簡體   English   中英

嘗試使用 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);

未處理的異常:Microsoft.Rest.HttpOperationException:機器人...不匹配從:...到:...

怎么了?

Message.From.Address 字段需要包含機器人 ID,如下所示:

var tBot = new ChannelAccount
{
    ChannelId = "telegram", Address = "salodkid_bot", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot"
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM