使用 LuisDialog 时传递机器人密码
Pass bot password when using LuisDialog
我需要在使用 LuisDialog 时动态传递 MS bot 密码。
我在处理系统消息时成功地做到了(请参阅我的代码中的其他部分)。但是当使用 Luis Diaog 时,由于它没有使用连接器对象,我得到了一个异常。
我有以下代码:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
try
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl), m_botAppId, m_botAppPassword);
if (activity.Type == ActivityTypes.Message)
{
// *how to pass the bot app password here???*
await Conversation.SendAsync(activity, () => new IntentHandler(m_cmConnectionString, m_luisModelId, m_luisModelKey, m_tfsUser, m_tfsPassword));
}
else
{
var reply = HandleSystemMessage(activity);
if (reply != null)
{
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
return Request.CreateResponse(HttpStatusCode.OK);
}
为什么要动态传递密码?
因为我们不想将机密存储在明文文件中并签入。我们也不想将其作为明文存储在 Azure.AppSettings 中,因为任何有权访问同一订阅的人都可以在那里看到明文形式的机密。
因此我需要存储加密的秘密,需要动态解密,然后将其传递给 bot 框架。
我通过在构造函数上动态设置 AppSettings 解决了这个问题。
ConfigurationManager.AppSettings[c_botAppPasswordSettingName] = m_botAppPassword;
这行得通。如果有人有其他想法,请随时告诉我。
我需要在使用 LuisDialog 时动态传递 MS bot 密码。
我在处理系统消息时成功地做到了(请参阅我的代码中的其他部分)。但是当使用 Luis Diaog 时,由于它没有使用连接器对象,我得到了一个异常。
我有以下代码:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
try
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl), m_botAppId, m_botAppPassword);
if (activity.Type == ActivityTypes.Message)
{
// *how to pass the bot app password here???*
await Conversation.SendAsync(activity, () => new IntentHandler(m_cmConnectionString, m_luisModelId, m_luisModelKey, m_tfsUser, m_tfsPassword));
}
else
{
var reply = HandleSystemMessage(activity);
if (reply != null)
{
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
return Request.CreateResponse(HttpStatusCode.OK);
}
为什么要动态传递密码? 因为我们不想将机密存储在明文文件中并签入。我们也不想将其作为明文存储在 Azure.AppSettings 中,因为任何有权访问同一订阅的人都可以在那里看到明文形式的机密。 因此我需要存储加密的秘密,需要动态解密,然后将其传递给 bot 框架。
我通过在构造函数上动态设置 AppSettings 解决了这个问题。
ConfigurationManager.AppSettings[c_botAppPasswordSettingName] = m_botAppPassword;
这行得通。如果有人有其他想法,请随时告诉我。