【问题标题】:Send query from bot framework emulator to teams and getting reply from teams to bot framework emulator从机器人框架模拟器向团队发送查询,并从团队向机器人框架模拟器获取回复
【发布时间】:2023-04-04 03:43:01
【问题描述】:
  • 我想将我的机器人模拟器连接到团队以发送查询(这是有效的)
  • 收到团队查询后,应将查询的答案发送回机器人模拟器

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

【问题讨论】:

  • 为了方便其他人帮助我建议您解释一下您尝试过的内容并分享您正在使用的代码或配置。
  • 您能详细解释一下您正在尝试做什么吗?可能不需要直接连接模拟器和 Teams。就个人而言,我发现我没有将模拟器用于仅限 Teams 的机器人 - 只需直接使用 Teams 客户端从您的机器人发送/接收消息

标签: botframework microsoft-teams


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    相关资源
    最近更新 更多