Resuable Web components for InLeads AI Driven Smart Sales Management System.
To use the Inleads Widgets in your project, install the package using npm:
npm install @inleads/inleads-widgets --save
yarn add @inleads/inleads-widgets
Install the Inleads Widgets Package in your Angular project:
npm install @inleads/inleads-widgets --save
yarn add @inleads/inleads-widgets
In main.ts, import and define the custom elements:
import { defineCustomElements } from '@inleads/inleads-widgets/loader'; // Add this
defineCustomElements(window); // Add this
In your app.module.ts, add CUSTOM_ELEMENTS_SCHEMA to avoid errors for unknown elements:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent]
})
export class AppModule {}
Once configured, you can utilize the Inleads Widgets components directly within your Angular templates. Below are the available components:
Next.js, being a React framework, requires some attention to server-side rendering (SSR) when using Web Components.
Install the Inleads Widgets package in your Next.js project:
npm install @inleads/inleads-widgets --save
yarn add @inleads/inleads-widgets
First, in your next.config.js, add the transpilePackages option to ensure the Inleads Widgets are transpiled:
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ["@inleads/inleads-widgets"], // Add this line
}
module.exports = nextConfig
Then, In your pages/_app.js, you need to conditionally load the Inleads Widgets only in the browser, not during SSR:
import { useEffect } from 'react';
import { defineCustomElements } from '@inleads/inleads-widgets/loader'; // Add this
function MyApp({pageProps }) {
useEffect(() => { // Add this
if (typeof window !== 'undefined') {
defineCustomElements(window);
}
}, []);
return <Component {...pageProps} />;
}
export default MyApp;
Once configured, you can utilize the Inleads Widgets components directly within your Next.js Pages. Below are the available components:
Since Next.js is built on React, the process is similar, but you don’t need to worry about SSR in plain React.
Install the Inleads Widgets package in your React.js project:
npm install @inleads/inleads-widget --save
yarn add @inleads/inleads-widget
To ensure that your Inleads Widgets components work correctly, you need to load them in your main React file index.js. Use the following code snippet:
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { defineCustomElements } from '@inleads/inleads-widgets/loader'; // Add this
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
defineCustomElements(window) // Add this
Once configured, you can utilize the Inleads Widgets components directly within your React.js templates. Below are the available components:
Easily integrate Inleads Widgets directly into an HTML file using the following script tags. This approach allows you to add Inleads Widgets without using any framework.
Include the following scripts in the section of your HTML file to load the Inleads Widgets components:
<head>
<!-- Import the Inleads Widgets Module -->
<script type="module" src="https://unpkg.com/@inleads/inleads-widgets@latest/dist/inleads-widgets/inleads-widgets.esm.js"></script>
<script nomodule src="https://unpkg.com/@inleads/inleads-widgets@latest/dist/inleads-widgets/inleads-widgets.js"></script>
</head>
Once the scripts are included, you can add the Inleads Widgets directly to the HTML body as custom HTML tags. Below are the available components:
Before integrating the Inleads Widgets components in your project, follow these steps based on your application framework.
Then,
<div>
// Insert the Chatbot Widget
<chatbot-widget api-key="" agent-id="" email-id="" user-name=""></chatbot-widget>
</div>
Before integrating the Inleads Widgets components in your project, follow these steps based on your application framework.
Then,
<div>
// Insert the Whatsapp Widget
<whatsapp-widget api-key="" phone-number="" ></whatsapp-widget>
</div>
Before integrating the Inleads Widgets components in your project, follow these steps based on your application framework.
Then,
<div>
// Insert the Contact Form Widget
<contact-form-widget api-key=""></contact-form-widget>
</div>
Before integrating the Inleads Widgets components in your project, follow these steps based on your application framework.
Then,
<div>
// Insert the NPS Widget
<nps-widget api-key="" background-color="" text-color="" ></nps-widget>
</div>
<whatsapp-widget api-key="" phone-number="" ></whatsapp-widget>
Property | Attribute | Type | Default | Required |
---|---|---|---|---|
apiKey |
api-key |
string |
undefined |
Yes |
phoneNumber |
phone-number |
string |
undefined |
Yes |
<contact-form-widget api-key=""></contact-form-widget>
Property | Attribute | Type | Default | Required |
---|---|---|---|---|
apiKey |
api-key |
string |
undefined |
Yes |
<chatbot-widget api-key="" agent-id="" email-id="" user-name=""></chatbot-widget>
Property | Attribute | Type | Default | Required |
---|---|---|---|---|
apiKey |
api-key |
string |
undefined |
Yes |
agentId |
agent-id |
string |
undefined |
Yes |
emailId |
email-id |
string |
undefined |
Optional |
userName |
user-name |
string |
undefined |
Optional |
<nps-widget api-key="" background-color="" text-color="" ></nps-widget>
Property | Attribute | Type | Default | Required |
---|---|---|---|---|
apiKey |
api-key |
string |
undefined |
Yes |
backgroundColor |
background-color |
string |
#1B1464 |
Optional |
textColor |
text-color |
string |
#ffffff |
Optional |