The chat widget enables you to interact with the AI customer support chatbot from your dashboard and see the changes in real-time. Open is a React web app that you can embed in your web app.
There are several ways you can integrate the chat widget into your application/webpage.
This will automatically register a new function called initOpenWidget on the global window object.
Init the widget (when document fully loads) by calling the initOpenWidget function and passing the required options.
There are plenty of options that you can pass to the widget, you can find them here
<script> const options = { /** ## Basic and required options ## */ token: "your_organization_token_goes_here", // (required) Settings -> Metadata -> Token initialMessages: ["Hey! happy to help."], // (optional) Messages that will be first present when the chat widget is initialized /** ## User identification options (optional) ## */ user: { name: "John Doe", email: "john@doe.com", avatar: "https://example.com/avatar.png", phone: "123456789", customData: { // any custom data you want to send to the Open backend, for example: "key1": "value1", } } // This widget supports AMAZING features and options. See the options documentation for more details. } window.addEventListener("DOMContentLoaded", ()=> initOpenScript(options)); // window.onload</script>
import{Widget,WidgetRoot,WidgetPopover}from"@openchatai/widget";import"@openchatai/widget/dist/style.css";const options ={/** ## Basic and required options ## */token:"your_organization_token_goes_here",// (required) Settings -> Metadata -> TokeninitialMessages:["Hey! happy to help."],// (optional) Messages that will be first present when the chat widget is initialized/** ## User identification options (optional) ## */user:{name:"John Doe",email:"john@doe.com",avatar:"https://example.com/avatar.png",phone:"123456789",customData:{// any custom data you want to send to the Open backend, for example:"key1":"value1",}},// This widget supports AMAZING features and options. See the options documentation for more details.}functionWidget(){return(<WidgetRootoptions={options}><Widget/>// the inline chat widget<WidgetPopover/>// optional, if you want to use the popover</WidgetRoot>)}
Any custom data that you want to send to the backend
initialMessages
array
The message that will be first present when the widget is initialized
triggerSelector
string
The selector of the element that will trigger the widget when clicked, if not set, a default trigger will be added to the root element (will show on bottom right of the screen)
apiUrl
string
The backend url of the widget api (default: https://api-v2.opencopilot.so/backend), you can use your own backend if you have one (open source or self hosted)
headers
Object
An object of headers that will be sent with every request to your backend (can be used to authenticate your api requests)
The url of the socket url that will be used to send and receive messages, it’s helpful if you want to use your own socket server (open source or self hosted)
One of the helpful options in the chat widget is the ability to identify the user/contact of the chat. This is useful if you want to track the usage of the chat widget.
To start identifying the user/contact, you can pass the user object as an option to the chat widget, for example:
const options ={initialMessages:["Hey! happy to help."],token:"your_organization_token_goes_here",// Settings -> Metadata -> Tokenuser:{name:"your_user_name",email:"your_user_email",avatar:"your_user_avatar_url",phone:"your_user_phone",customData:{// any custom data you want to send to the Open backend"key1":"value1",}},}
Make sure that the triggerSelector is correct and the element exists in
the dom,instead you can set defaultOpen to true to make the widget open by default.
if that did not work, please open an issue on our GitHub repo
The widget is responsive and it’s width is set to 100% by default of the container, you can change that by passing the
containerProps option and setting the width to whatever you want.