OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.26k stars 170 forks source link

Is it possible to add it into an existing website which we can only add some js snippets in header or footer? #205

Open sprklinginfo opened 1 month ago

sprklinginfo commented 1 month ago

My company's website is built with commercial software which is managed by an IT team. As an admin of my department, I can add new pages with a predefined template. only a subset of approved HTML tags are allowed. so <deep-chat>tag won't stay. but I can use <script> tag to add some small js functions to enhance a page a little bit. is there a way I can wrap <deep-chat> component into a <script> tag and drop it on an existing page? The goal is to display it as a float button at the lower-right corner of a web page, as described on this issue. Another real live example is a library website, the 'Ask us live' button at the lower-right corner of the page. I am a little confused how it is implemented. any suggestions or ideas are much appreciated.

OvidijusParsiunas commented 3 weeks ago

Hi @sprklinginfo, You can use the JavaScript example to import Deep Chat using <script>. You can then embed it into your markup via the following JavaScript:

const chatContainerEl = document.getElementById('chat-container');
// the following code is in a timeout to make sure the script has loaded
setTimeout(() => {
  const chatEl = document.createElement('deep-chat');
  chatEl.demo = true; // example to set properties
  chatContainerEl.appendChild(chatEl);
}, 100); // the number may need to be increased depending on how long it takes to download the script

TIP: You can speed up the script download by storing it alongside with your project by downloading the following file, storing it along with your project as a static asset and pointing to it in the script tag's src attribute.

Let me know if this helps.

sprklinginfo commented 3 weeks ago

thanks. I will try it.