SAP/Webchat

Problem with page events after Webchat loads

sathianarayananh opened this issue ยท 6 comments

Problem Description
When Webchat loads in a page, it breaks some features of the page. For example - auto suggest or button doesn't work.

Steps to reproduce

  1. Open Chrome and go to [(https://www.google.com/)]
  2. Open Developer Tools --> Console.
  3. Copy-paste the below code to dynamically load the Webchat script (add your channelid and token in below script).

window.loadRecastAI = function () { var oElem = document.createElement("div"); oElem.id = "recast-ai"; var oScript = document.createElement("script"); oScript.setAttribute('src', 'https://cdn.recast.ai/webchat/webchat.js'); oScript.setAttribute('channelId', '**Insert your Channel ID here**'); oScript.setAttribute('token', '**Insert your Token here**'); oScript.setAttribute('id', 'recast-webchat'); oElem.appendChild(oScript); document.body.appendChild(oElem); }; window.loadRecastAI();

  1. Now type something in google search text box. The auto suggest should not work. Also click on Microphone button, it should do nothing.

I had some bug like this, my correction was to make a correction in the webchat's code :

Before (src/script.js)

document.body.innerHTML += '<div id="recast-webchat-div"></div>'

After (src/script.js)

const element = document.createElement("div")
element.id = "recast-webchat-div"
document.body.appendChild(element)

document.body.innerHTML += is very unsafe as it re-renders the page, breaking some things.

I tested your code @DiesIrae and it works well.
Do you want to make a pull request?

I've hosted temporary the script with your fix to test here: https://cdn.recast.ai/webchat/webchat_debug_one.js.

@DiesIrae Thanks for your quick reply, it works ๐Ÿ‘

When I spoke with the Recast team last year, it seemed that your were not interested to PRs directly, so I forked privately and developped lots of stuff on my own.
Sure, I can make a PR.

@DiesIrae Interested to know what stuffs you developed as I am also doing some custom development with Webchat. If you have a repo to fork, please let me know.

@DiesIrae It is complicated for us to add new features because of the roadmap & product owner, but bug fixes are always interesting.
Thank you for your contribution.