0.2.17 • Published 3 months ago

dvijay-project-demo1 v0.2.17

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

InLeads

Resuable Web components for InLeads AI Driven Smart Sales Management System.

Getting Started

Installation

To use the Inleads Widgets in your project, install the package using npm:

NPM

npm install @inleads/inleads-widgets --save

Yarn

yarn add @inleads/inleads-widgets

Usage

Using Inleads widgets Components in Angular

Step 1: Install the Inleads Widgets Package

Install the Inleads Widgets Package in your Angular project:

NPM

npm install @inleads/inleads-widgets --save

Yarn

yarn add @inleads/inleads-widgets

Step 2: Define Custom Elements in Angular

In main.ts, import and define the custom elements:

import { defineCustomElements } from '@inleads/inleads-widgets/loader'; // Add this
defineCustomElements(window); // Add this

Step 3: Add CUSTOM_ELEMENTS_SCHEMA

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 {}

Step 4: Use the Inleads Widgets in Templates

Once configured, you can utilize the Inleads Widgets components directly within your Angular templates. Below are the available components:

Using Inleads Widgets Components in Next.js

Next.js, being a React framework, requires some attention to server-side rendering (SSR) when using Web Components.

Step 1: Install the Inleads Widgets Package

Install the Inleads Widgets package in your Next.js project:

NPM

npm install @inleads/inleads-widgets --save

Yarn

yarn add @inleads/inleads-widgets

Step 2: Load Web Components in Browser (Avoid SSR Issues)

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;

Step 3: Use Widgets in Pages

Once configured, you can utilize the Inleads Widgets components directly within your Next.js Pages. Below are the available components:

Using Inleads Widgets Components in React.js

Since Next.js is built on React, the process is similar, but you don’t need to worry about SSR in plain React.

Step 1: Install the Inleads Widgets Package

Install the Inleads Widgets package in your React.js project:

NPM

npm install @inleads/inleads-widget --save

Yarn

yarn add @inleads/inleads-widget

Step 2: Load Inleads Widgets Components

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

Step 3: Use Widgets in Components

Once configured, you can utilize the Inleads Widgets components directly within your React.js templates. Below are the available components:

Using Inleads Widgets Components Integration in HTML

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.

Step 1: Add Inleads Widgets Scripts

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>

Step 2: Add the Widget to Your HTML Body

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:

Chatbot Widget

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>

Whatsapp Widget

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>

Contact Form Widget

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>

NPS Widget

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>

Functions Reference

Inleads Widgets :-

Whatsapp Widget

<whatsapp-widget api-key="" phone-number="" ></whatsapp-widget>

Properties

PropertyAttributeTypeDefaultRequired
apiKeyapi-keystringundefinedYes
phoneNumberphone-numberstringundefinedYes

Contact Widget

<contact-form-widget api-key=""></contact-form-widget>

Properties

PropertyAttributeTypeDefaultRequired
apiKeyapi-keystringundefinedYes

Chatbot Widget

<chatbot-widget api-key="" agent-id="" email-id="" user-name=""></chatbot-widget>

Properties

PropertyAttributeTypeDefaultRequired
apiKeyapi-keystringundefinedYes
agentIdagent-idstringundefinedYes
emailIdemail-idstringundefinedOptional
userNameuser-namestringundefinedOptional

NPS Widget

<nps-widget api-key="" background-color="" text-color="" ></nps-widget>

Properties

PropertyAttributeTypeDefaultRequired
apiKeyapi-keystringundefinedYes
backgroundColorbackground-colorstring#1B1464Optional
textColortext-colorstring#ffffffOptional
0.2.17

3 months ago

0.2.15

3 months ago

0.2.14

3 months ago

0.2.13

3 months ago

0.2.12

7 months ago

0.2.11

7 months ago

0.2.10

7 months ago

0.2.9

7 months ago

0.2.8

7 months ago

0.2.1

8 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.4

8 months ago

0.2.0

8 months ago

0.1.0

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

2.0.8

8 months ago

2.0.7

8 months ago

2.0.6

8 months ago

2.0.5

8 months ago

2.0.4

8 months ago

2.0.3

8 months ago

2.0.2

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.0.23

9 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

0.0.1

9 months ago