ServiceNow 上的 BOT 框架示例 12 实现

BOT framework sample 12 implementation on ServiceNow

我正在使用sample12 to create a minimizable webchat on the ServiceNow page. Using sample 12 and building the same, I was able to import it to ServiceNow and get to the point where it appears on a new UI page. But there are two issues 1) CORS 2)Authentication to the BOT isnt happening.

此外,我该如何进行身份验证?

我使用以下 process 来托管页面

有什么想法吗? 这种嵌入(如下所示)对我们有用。但是我们需要在 servicenow

上进行最小化的网络聊天

我现在通过托管一个返回令牌的应用程序服务来完成这项工作。该应用程序现在可以访问 BOT。

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web.Mvc;
using Newtonsoft.Json.Linq;
using WebApplication1.Controllers;

namespace WebApplication1.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    public class DirectLineController : Controller
    {
        //[HttpPost]
        //public async Task<string> PartialToken()
        //{
        //    string data = await GetToken(false);
        //    return data;
        //}


        //[HttpGet]
        //public async Task<string> Token()
        //{
        //    string data = await GetToken(true);
        //    return data;
        //}
        [HttpPost]
        public async Task<string> GetToken()
        {
            string data = String.Empty;
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
                    "Hir-4RmrbUY.cwA.aqo.ojSLtakhThiswontworkdonteventrym64oi_2LE_sB4C5BizQwaCg__q1M");
                var response = await client.PostAsync("https://directline.botframework.com/v3/directline/tokens/generate", null);
                if (response.IsSuccessStatusCode)
                {
                    var raw = await response.Content.ReadAsStringAsync();
                    if (true)
                    {
                        data = raw;
                    }
                    else
                    {
                        data = JObject.Parse(raw)["token"].Value<string>();
                    }
                }
            }

            return data;
        }

        //protected override void ExecuteCore()
        //{
        //    throw new NotImplementedException();
        //}
    }
}