如何使用 BotAuthentication botframework v3
How to use BotAuthentication botframework v3
我正在尝试根据 this 发出主动消息。
我能理解它的方法。我担心安全问题。所以我正在尝试使用 BotAuthentication。但我不知道如何使用它。我尝试根据 this.
添加令牌
不过好像没什么用。如何使用BotAuthentication?对了,我需要担心安全问题吗?
using Bot.Dialogs.FAQ.Liquidation;
using Bot.Dialogs.Menu;
using Bot.Resources;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Resources;
using System.Threading.Tasks;
using System.Web.Http;
namespace Bot
{
[BotAuthentication]
public class CustomWebAPIController : ApiController
{
[HttpGet]
[Route("api/CustomWebAPI")]
public async Task<HttpResponseMessage> SendMessage()
{
try
{
if (!string.IsNullOrEmpty(ConversationStarter.conversationReference))
{
await ConversationStarter.Resume(); //We don't need to wait for this, just want to start the interruption here
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent($"<html><body>Message sent, thanks.</body></html>", System.Text.Encoding.UTF8, @"text/html");
return resp;
}
else
{
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent($"<html><body>You need to talk to the bot first so it can capture your details.</body></html>", System.Text.Encoding.UTF8, @"text/html");
return resp;
}
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
}
}
我正在尝试根据 this 发出主动消息。
我能理解它的方法。我担心安全问题。所以我正在尝试使用 BotAuthentication。但我不知道如何使用它。我尝试根据 this.
添加令牌不过好像没什么用。如何使用BotAuthentication?对了,我需要担心安全问题吗?
using Bot.Dialogs.FAQ.Liquidation;
using Bot.Dialogs.Menu;
using Bot.Resources;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Resources;
using System.Threading.Tasks;
using System.Web.Http;
namespace Bot
{
[BotAuthentication]
public class CustomWebAPIController : ApiController
{
[HttpGet]
[Route("api/CustomWebAPI")]
public async Task<HttpResponseMessage> SendMessage()
{
try
{
if (!string.IsNullOrEmpty(ConversationStarter.conversationReference))
{
await ConversationStarter.Resume(); //We don't need to wait for this, just want to start the interruption here
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent($"<html><body>Message sent, thanks.</body></html>", System.Text.Encoding.UTF8, @"text/html");
return resp;
}
else
{
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent($"<html><body>You need to talk to the bot first so it can capture your details.</body></html>", System.Text.Encoding.UTF8, @"text/html");
return resp;
}
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
}
}