【问题标题】:BOT framework sample 12 implementation on ServiceNowServiceNow 上的 BOT 框架示例 12 实现
【发布时间】:2019-07-01 11:19:33
【问题描述】:

我正在使用sample12 在 ServiceNow 页面上创建一个最小化的网络聊天。使用示例 12 并构建相同的示例,我能够将其导入到 ServiceNow 并到达它出现在新 UI 页面上的位置。但是有两个问题 1)CORS 2)对 BOT 的身份验证没有发生。

另外,我该如何处理身份验证?

我使用以下process 来托管页面

有什么想法吗? 这种嵌入(如下所示)对我们有用。但是我们现在需要一个最小化的 servicenow 网络聊天

【问题讨论】:

  • 您希望如何对页面的其余部分使用机器人身份验证?是对用户进行身份验证以访问页面功能,对机器人进行身份验证以使其正常工作,还是其他什么?
  • 所以用户现在登录服务。我可以从这些字段中获取这些详细信息用户ID:c.data.botUserEmail,用户名:c.data.botUserEmail,然后可以传递给聊天机器人。我们已经准备好一种嵌入式网络聊天,但我们需要更多类似最小化的聊天。我现在将更新我在主要问题上尝试过的事情。
  • @StevenKanberg 您能否建议如何进行这项工作?

标签: botframework web-chat


【解决方案1】:

我现在通过托管一个返回令牌的应用服务来完成这项工作。该应用现在可以访问 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();
        //}
    }
}

【讨论】:

    猜你喜欢
    • 2017-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2014-03-02
    相关资源
    最近更新 更多