简体   繁体   English

从 Bot Composer 生成的代码访问 turnContext

[英]Accessing turnContext from Bot Composer generated code

I have created a chat bot using Bot Framework Composer, and I'm trying to get the plain text of the different conversation turns, for logging purposes.我已经使用 Bot Framework Composer 创建了一个聊天机器人,并且我正在尝试获取不同对话轮次的纯文本,以用于记录目的。

I have found this resource , where it explains how to do it, but it only applies for the Microsoft Bot Framework v4 sdk.我找到了这个资源,其中解释了如何操作,但它仅适用于 Microsoft Bot Framework v4 sdk。

However, since the code generated by Framework Composer and Bot Framework SDK is different I don't know how to access the Activity object or the turnContext info.但是,由于 Framework Composer 和 Bot Framework SDK 生成的代码不同,我不知道如何访问 Activity object 或 turnContext 信息。

Is there any way to access this info from the code generated by Bot Framework Composer?有没有办法从 Bot Framework Composer 生成的代码中访问此信息?

I have tried printing from SkillController.cs and BotController.cs.我试过从 SkillController.cs 和 BotController.cs 进行打印。 However, the Activity object that might contain the turnContext is empty.但是,可能包含 turnContext 的活动 object 是空的。

Write the custom middleware to access turn context object here the video steps how to create custom middleware using bot composer编写自定义中间件以访问 turn context object 视频步骤如何使用bot composer创建自定义中间件

Follow the following steps:-请按照以下步骤操作:-

1.Ask for input text and than store it using "Set a property". 1.询问输入文本,然后使用“设置属性”存储它。 管理属性>>设置属性

2.If you want you can give different variable names each time whenever you want to store user response. 2.如果你愿意,每次你想存储用户响应时,你都可以给不同的变量名。 添加变量名

3.You can use the variable name to access the response. 3.您可以使用变量名来访问响应。 在此处输入图像描述

Here is the output:-这是 output:- 输入你想要的内容>>Help me>>用户回复:-Help me

And you can also merge it in a loop for storing multiple response.您还可以将其合并到一个循环中以存储多个响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM