xatkit-bot-platform / xatkit-chat-widget

(React) Chat widget for Xatkit
https://xatkit.com
MIT License
5 stars 2 forks source link

Is the widget aware of the page where it's embedded in? #31

Closed jcabot closed 4 years ago

jcabot commented 4 years ago

Talking with Joan Giner, he mentioned that clients typically want to correlate the chatbot usage with the pages where a specific question/issue was posed. In short, they want to know what pages generate plenty of questions (which means that those pages are not clear enough).

hamzaed commented 4 years ago

We can access the page URL within the widget using window.location.href or for a cleaner solution we can embed the widget inside a RouteComponent then get the location from the props.location. Then we should send the URL alongside the user's message to the server and store it in the database.

hamzaed commented 4 years ago

I added hostname and url to the args object of Socket.IO such as:

I can add more information such as the web protocol.

@gdaniel we should work on the server side to process this.

Hamza

jcabot commented 4 years ago

Who is filling the parameters? As part of the call to renderWidget?

hamzaed commented 4 years ago

For now, these parameters are extracted automatically. We were discussing if we should allow the user to override their values by adding optional parameters to renderWidget.

Hamza

jcabot commented 4 years ago

I can't give a concrete example but I guess there will be situations where due to some strange internal URL forwardings, the "public" URL of the website where the widget is embedded may not be exactly the same one you'd get by extracting it automatically.

gdaniel commented 4 years ago

Nice job @hamzaed! I can't think of an example with such URL forwarding but I agree this could be configurable somehow. I also think that we should have it automatically extracted if not provided, no need to rely on a parameter if we can get the information by ourselves.

hamzaed commented 4 years ago

Thanks @gdaniel

I added hostname and url to the list of parameters of renderXatkitWidget. I don't do any extra checking: if a parameter exists, I take it otherwise I extract the value directly.

The new signature of renderXatkitWidget is the following: renderXatkitWidget(server, username, elementId, title, subtitle, startMinimized, senderPlaceholder, profileAvatar, launcherImage, buttonsPlaceholder, hostname, url)