botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How do I use Activity to get current page URL

Open CalvinFengDatacom opened this issue 8 years ago • 3 comments

Issue Description

I have already hosted a bot inside a web page. But, I can't find a way to get the page URL from bot framework. Because we need to display different messages according to different page URL. For example, we have a page for booking and another page for shopping. So, we can only know from the page URL about which page is currently displaying, then we can do some condition checks and switch over some logic.

I have tried to get page url from the following code, but I can only get null. activity.From.Properties["Referer"]

CalvinFengDatacom avatar May 01 '18 04:05 CalvinFengDatacom

The activity does not contain this information, what you are trying to do does not exist. You are going to have to use other means to get it, maybe set up a 302 redirect that can collect this information prior to hitting the bot then redirects to the bot.

JasonSowers avatar May 01 '18 16:05 JasonSowers

@CalvinFengDatacom You could intercept outgoing DirectLine messages and add channel data that specifies the page that originated the call: https://github.com/Microsoft/BotFramework-WebChat/issues/395#issuecomment-289681256

EricDahlvang avatar May 01 '18 16:05 EricDahlvang

@EricDahlvang Oh, I see what you mean. So, I need to get the value of page URL and assemble it into Activity, then send back to Bot. I will try this. Thank you

CalvinFengDatacom avatar May 01 '18 21:05 CalvinFengDatacom