SAP/Webchat

The webchat should provide some context information from the web page to the bot actions

christianroy opened this issue · 8 comments

Intro

I asked the question about this feature on the Recast community Slack group and had some feedback from Oliver Nguyen who confirmed that it was not supported. So the following is an attempt to explain the use cases and why this would be useful.

I am making those notes as an issue in the Webchat project, but I understand this may have broader implications (probably not only a webchat concern). Let me know if there is a better place to submit this issue.

Use case

I am building a bot for a client. The bot basically answers the same types of questions, with the same skills and the same “knowledge base” (through webhooks calls in the actions), for many instances of the client product. Each instance is a different website, and the instance information is important for the bot to get the right answer.

More concretely:

  • webchat is embedded on domain1.com AND domain2.com
  • when the user asks “what are your opening hours”, the answer is different depending if the user is on domain1.com or domain2.com
  • currently, the message that will be send to the bot backend (webhook type of action for that skill) does not include any information that allows to know the webchat context (domain1 or domain2)
  • so the bots needs to ask the user for their context (eg. “are you shopping on domain1 or domain2?”)

I am sure there are other similar situations. For instance, a support bot on an ecommerce site should know what product the user is asking about if he/she is on a product page.

Proposed implementations

I have no prefered implementation, as long as there is a way to know “where” / “in what context” the webchat was used, from the message that is sent to my API through the webhook actions. Here are a few ideas.

Referring URL

Simply having the URL of the page containing the webchat as a new property of the message object would work. Very simple to implement from my bot developper point of view.

channelId

I could create multiple webchat connectors, each of which have a unique channelId. Now, if the channelId information was sent as a property of the message object, that would work as well. This is a bit more tedious however, and would not really scale well for some use cases (eg. the ecommerce example above).

Custom attribute in the script tag

Just like the channelId, we could add a property to the script tag for embedding the webchat, and that info would be send in the message object (or injected in the bot memory right from the start of the conversation?). Also easy to implement from my developer perspective.

Hi @christianroy , thanks for the thorough report :) I understand that you would like to have custom data attached to conversation/messages, and be able to access this custom data when building answers to user messages. One very simple thing I have in mind would be to allow developers to define a conversationStart hook/callback when initializing the webchat, that would be called with the id of the conversation as an argument when the user sends the first message in the conversation.

The developer can then send arbitrary data he knows about the user to his backend, and when receiving messages from the user, the bot can query the backend for the arbitrary data. Would that do it for you in this case ?

Thaks for the quick reply @dbousque!

Would the hook/callback be browser side code? If so, I guess that would work: some JS code in the browser would call the backend to store data using the conversation id as key. Then when receiving a message, the backend could use that same key (the conversation id) to fetch that data.

In my specific case, the client does not want to store user data for legal reason, but storing context specific information anonymously based on the conversation ID would work.

If the hook/callback is not called on the browser side... then I am not sure I understand how this would work. :-\

Yes absolutely, I meant browser side hook/callback :) @jhoudan , how does it sound ?

Definitely would be great to be able to instantiate a conversation with a provided json memory ; thus allowing to trigger different scenarios (skills, questions) depending on what's in the memory.

Any news on this ?

From what I can understand from reading the README part in this commit it seems that we have a solution now! I have not tried it yet though. @OlivierNguyen I am right in thinking that the new memory management feature is exactly the solution we discussed above? If so I guess we could close this issue... :-)

Hi @christianroy, yes you're exactly right, you can read more here : https://recast.ai/docs/concepts/webchat :)

Excellent! Thanks!