我在我的网站中使用了直接线,我想知道是否有从Request头的Referrer和Origin告诉网站的URL,我想在Dialog中获取值,我尝试过使用Activity。 ServiceUrl但是它提供了directline.botframework.com,而HttpContext.Current.Request.Url.AbsoluteUri
正在提供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; }
答案 0 :(得分:0)
如果您想获取在bot应用程序对话框中嵌入webchat的网页的URL,您可以尝试获取URL并将其传递给您的机器人,如下所示:
<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();
}
测试结果: