从Microsoft Bot Framework获取URL Referer和Origin标头 [英] Get URL Referer and Origin header from Microsoft Bot Framework

查看:122
本文介绍了从Microsoft Bot Framework获取URL Referer和Origin标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站内部使用了一条直线,我想知道是否仍然可以通过Request标头Referrer和Origin告诉网站的网址,我想在Dialog中获取该值,我尝试使用Activity. ServiceUrl,但它给出的是directline.botframework.com,而HttpContext.Current.Request.Url.AbsoluteUri是给出的Azure URL.

I am using a directline inside my website, I was wondering if there is anyway to tell the URL of the website from the Request header Referrer and Origin, I want to get the value inside a Dialog, I have tried using Activity.ServiceUrl but it is giving directline.botframework.com and the HttpContext.Current.Request.Url.AbsoluteUri is giving the Azure URL.

   public Task StartAsync(IDialogContext context)
    {
        context.Wait(MessageReceivedAsync);
        return Task.CompletedTask;
    }

    private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
    {
        var activity = await result as Activity;                      }

推荐答案

如果您想获取将Webchat嵌入到bot应用程序Dialog中的网页的URL,则可以尝试获取该URL并将其传递给您机器人,像这样:

If you’d like to get the URL of the webpage where you embed webchat inside bot application Dialog, you can try to get the URL and pass it to your bot, like this:

<script>
    var urlref = window.location.href;

    BotChat.App({
        directLine: { secret: "{directline_secret}" },
        user: { id: 'You', referrer: urlref},
        bot: { id: '{bot_id}' },
        resize: 'detect'
    }, document.getElementById("bot"));
</script>

内部漫游器对话框:

if (activity.From.Properties["referrer"] != null)
{
    var urlref= activity.From.Properties["referrer"].ToString();
}

测试结果:

这篇关于从Microsoft Bot Framework获取URL Referer和Origin标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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