# Embeddable JavaScript Snippet

What if you could integrate a conversational search window into your website to facilitate instant responses to product-related queries? With the embeddable JavaScript snippet, you can do just that. This feature allows you to copy and embed a simple JavaScript code snippet into your website, typically placed at the bottom right corner of your site.

## Pre-requisites

If you want to embed the JavaScript snippet into your other website, you need to enable it in `.env` file. 

* Step 1: Enable the JavaScript Widget

```bash
# JS Widgets: if you want to use JS widgets, you need to set the following variables to enable CORS.
BACKEND_CORS_ORIGINS=https://your-domain.com
```

* Step 2: Restart your service

## How to Embed

To embed the JavaScript snippet, follow these steps:

1. Enter Settings > JavaScript, and copy the JavaScript code snippet like this:

![embeddable-javascript-snippet](https://github.com/user-attachments/assets/5322dc31-d4d5-492f-87dd-dd976c245ac3)

2. Paste the JavaScript code snippet into your website's HTML file;

3. Initialize the JavaScript snippet with input parameters like `Widget Title`, `Site Name`, `Search Titles`, `Example Questions`, `Footer Links`, and `Social Media Links`;

4. Restart your website to see the conversational search window appear at the bottom right corner of your site.

![embeddable-javascript-snippet](https://github.com/user-attachments/assets/f0dc82db-c14d-4863-a242-c7da3a719568 "Image Title")

That's all you need to do to integrate our conversational search window into your website. Enjoy! You can also go to https://tidb.ai and https://docs.pingcap.com to see the chat window in action.
