# @openchatai/copilot-widget

> This is the widget for OpenCopilot: it's what your users will interact with.

Latest version **2.8.12** (published 2024-03-19) · 0 weekly downloads

## Install

```sh
npm install @openchatai/copilot-widget
pnpm add @openchatai/copilot-widget
yarn add @openchatai/copilot-widget
bun add @openchatai/copilot-widget
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.8.12 |
| Published | 2024-03-19 |
| First published | 2023-09-28 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | openchatai |
| Maintainers | shanurrahman1, ah7255703 |

## Links

- npm: https://www.npmjs.com/package/@openchatai/copilot-widget
- Issues: https://github.com/openchatai/OpenCopilot/issues
- npm.io page: https://npm.io/package/@openchatai/copilot-widget

## Dependencies (6)

- [immer](https://npm.io/package/immer.md) ^10.0.3
- [@rjsf/core](https://npm.io/package/@rjsf/core.md) ^5.17.1
- [@rjsf/utils](https://npm.io/package/@rjsf/utils.md) ^5.17.1
- [lucide-react](https://npm.io/package/lucide-react.md) ^0.298.0
- [@rjsf/validator-ajv8](https://npm.io/package/@rjsf/validator-ajv8.md) ^5.17.1
- [@openchatai/copilot-widget](https://npm.io/package/@openchatai/copilot-widget.md) ^2.8.1

## Recent versions

- 2.8.12 (latest) — 2024-03-19
- 2.8.11-beta.0 (beta) — 2024-03-18
- 2.8.11 — 2024-03-19
- 2.8.10 — 2024-03-17
- 2.8.9 — 2024-03-16
- 2.8.8 — 2024-03-15
- 2.8.7 — 2024-03-15
- 2.8.6 — 2024-03-14
- 2.8.5 — 2024-03-12
- 2.8.4 — 2024-03-12
- 2.8.3 — 2024-03-12
- 2.8.2 — 2024-03-11
- 2.8.1 — 2024-03-11
- 2.8.0 — 2024-03-11
- 2.8.0-beta.6 — 2024-03-10
- … 48 more at https://npm.io/package/@openchatai/copilot-widget/versions

## README

# OpenCopilot widget

This is the widget for OpenCopilot: it's what your users will interact with.

It's a simple React application that can be used in any webpage as a widget. To download the latest build of the widget, go to the actions tab in GitHub and download the latest build artifact.

## How to install

1. Download the latest build artifact from the actions tab.

2. Extract the zip file.

3. Copy the `assets/*.js` file to your project.

4. Reference the js file in your HTML file as follows:

   ```html
   <script src="[some_js_file].js"></script>
   ```

5. Initialize the widget.

   ```html
   <script>
     // you should run it after window loads
     window.onload = () => {
       initAiCoPilot({
         initialMessage: "Hey, how can I help you today?", // initial bot message
         token: "not_super_secret_token", // your OpenCopilot token
         rootId: "copilot-widget", // @optional: the root element id in which the widget will mount on
         triggerSelector: "#triggerSelector", // the selector of the element that will trigger the widget on click
         apiUrl: "https://cloud.openchat.so/api", // the url of the OpenCopilot api.
         headers: {
           Authorization: "Bearer your_auth_token_goes_here",
         }, // @optional: headers that you want to send with every message request
         bot: {
            name: "AI Assistant",
            avatarUrl: "https://example.com/company-logo.png"
         }, // @optional: bot object – this info will be used in the chat
         user: {
            name: "John Doe",
            avatarUrl: "https://example.com/user-avatar.png"
         }, // @optional: user object – this info will be used in the chat
         containerProps: {}, // @optional: `HTMLProps`
         warnBeforeClose: true, // @optional: Set to false if you don't want to warn the user before closing the chat
         onClose: () => {
            console.log('Closing chat window.');
         } // @optional: Callback before closing the chat
       });
     };
   </script>
   ```

## How to use

1. Click on the trigger element to open the widget.

2. Type your message and press enter to send it.

<img width="394" alt="OpenCopilot widget" src="https://github.com/openchatai/OpenCopilot/assets/32633162/77b30faa-c59e-4a3a-821a-d14a61a49a65">

---
_Source: https://npm.io/package/@openchatai/copilot-widget · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
