user8321763
user8321763

Reputation: 149

Get logged in user data from the website it is currently hosted

Can we somehow get the curret state of website where the bot is embedded as IFrame?

As in for example, the bot validates whether the user is logged in or not, or his login credentials. Hence, I should be able to pass user's account id along with some other info as well into the bot's code. Then, accordingly, the bot displays the options differently.

I've seen such bots implemented on Industry Websites using bot framework itself. So, any idea how to work this around?

Upvotes: 2

Views: 226

Answers (3)

Anita George
Anita George

Reputation: 1153

I should be able to pass user's account id

You can pass the user's id and name using the embedded code.

<iframe src='https://webchat.botframework.com/embed/bothandle?s=YOUR_SECRET_HERE&username=YOUR_USER_NAME&userid=YOUR_USER_ID'></iframe>

To pass details other than the user id and user name you need to use the backchannel method in the web-chat repo. Here is a sample doing the same.

Upvotes: 2

Nicolas R
Nicolas R

Reputation: 14619

Hence, I should be able to pass user's account id along with some other info as well into the bot's code. Then, accordingly, the bot displays the options differently.

Use webchat's backchannel functionality. You will have to switch from the basic iFrame to a few more lines of code, but it's working well.

  • Change the webchat implementation on the front side
  • Add the post of an activity to send the necessary information (still on the front side)
  • Get this activity on your bot side and handle it

See my other reply around this functionality here: How do I get the locale in conversationUpdate activity?

Upvotes: 3

Martin Zikmund
Martin Zikmund

Reputation: 39082

While it is possible to access the parent page from IFrame using JavaScript's window.parent, I doubt that it is the ideal approach. A better solution would be to expose an web API that would provide the required data, which would the bot's code call to access required information.

Upvotes: 2

Related Questions