从bot框架模拟器向团队发送查询,并从团队获得对bot框架模拟器的回复


  • 我想将我的机器人模拟器连接到发送查询的团队(这正在工作(
  • 一旦我们在团队中收到查询,查询的答案应该发送回机器人模拟器

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

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

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团队的响应发送到网络聊天机器人,以下代码有效:

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);

相关内容

最新更新