1
  • 我想将我的机器人模拟器连接到团队以发送查询(这是有效的)
  • 一旦我们收到团队中的查询,查询的答案应发送回机器人模拟器

我没有收到团队对机器人模拟器的回答

4

1 回答 1

0

要从网络聊天连接到我正在使用以下代码的团队:

string teamsChannelId = "****************************";
string serviceUrl = "****************************";
string botClientID = "****************************";
string botClientSecret = "****************************";
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);
var connectorClient = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials(botClientID, botClientSecret));
var topLevelMessageActivity = MessageFactory.Text(saveconv);
var conversationParameters = new ConversationParameters
{
    IsGroup = true,
    ChannelData = new TeamsChannelData
    {
        Channel = new ChannelInfo(teamsChannelId),
    },
    Activity = topLevelMessageActivity
};
await connectorClient.Conversations.CreateConversationAsync(conversationParameters);

要将 Microsoft 团队的响应发送到 Web 聊天机器人,代码如下:

var userAccount = new ChannelAccount(id: "userid", name: "username", role: "user", aadObjectId: null);
var botAccount = new ChannelAccount(id: "botid", name: "botname", role: "bot", aadObjectId: null);
string botClientID = "****************************";
string botClientSecret = "****************************";
string serviceUrl = "****************************";
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);
var connector = new ConnectorClient(new Uri(serviceUrl), new MicrosoftAppCredentials(botClientID, botClientSecret));
IMessageActivity message = Activity.CreateMessageActivity();
message.ChannelId = "channelid";
message.From = botAccount;
message.Recipient = userAccount;
message.Conversation = new ConversationAccount(id: "conversationid");
message.Text = "Reply from Microsoft Teams: *" + turnContext.Activity.Text;
message.Locale = "en-us";
await connector.Conversations.SendToConversationAsync((Activity)message);
于 2020-11-18T19:15:11.743 回答