2

我正在制作一个连接到网络聊天频道的机器人。但是,在用户输入的特定消息上,我想在 Directline 频道上向已与之建立连接的其他用户发送消息。

我有 Directline 频道上用户的 id、name 和 conversationID,所以我尝试过这样的事情:

var msg1 = await result as Activity;       //Message from Webchat channel
IMessageActivity message = Activity.CreateMessageActivity();

message.From = new ChannelAccount(name: "Bolo", id: "bol24x7");
message.Recipient = new ChannelAccount(name: "Auto", id: "aa24x7");
message.Conversation = new ConversationAccount(id: "GxBTy2R7nDq94FEvAvBd5A");
message.ChannelId = "directline";
message.Text = "1234";

var connector3 = new ConnectorClient(new Uri("https://directline.botframework.com/"));

if (msg1.Text == "1234") {
await connector3.Conversations.SendToConversationAsync((Activity)message);
}

但是,我收到此错误:“抱歉,我的机器人代码有问题。” 我能做些什么?

4

1 回答 1

0

由于直达通道与来自的一条消息不同,因此您需要将其服务 url 标记为 trust 然后 intialize connector3,如下所示:

MicrosoftAppCredentials.TrustServiceUrl("https://directline.botframework.com/", DateTime.Now.AddDays(1));

var account = new MicrosoftAppCredentials("MicrosoftAppId", "MicrosoftAppPassword");

var connector3 = new ConnectorClient(new Uri("https://directline.botframework.com/"), account);
于 2017-06-25T11:51:24.790 回答