BOT框架示例12在ServiceNow上的实现 [英] BOT framework sample 12 implementation on ServiceNow

查看:138
本文介绍了BOT框架示例12在ServiceNow上的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

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

Also, how do I take care of authentication?

我使用以下流程来托管页面

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

Any ideas ? This sort of embed (as shown below) is working for us. But we need a minimizable webchat on servicenow

推荐答案

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

I now got this working by hosting a app service returning the token. The app is now able to access the 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();
        //}
    }
}

这篇关于BOT框架示例12在ServiceNow上的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆