# Admin and Vendor Chat Addon

**Installation of Spurtcommerce** **Admin and vendor chat  add-on**

This document will help you to install Admin and vendor chat  add-on to your spurtcommerce server for single vendor as well as multi vendor

### <mark style="color:blue;">Server setup</mark>

Include variable 'SOCKET\_PORT' in ENV configuration File

Eg: SOCKET\_PORT=8001

In apache configuration specify/include below ProxyPass rules inside virtual host in 000-default.conf

**Step -1**:

```
$ cd /etc/apache2/sites-available/
$ sudo nano 000-default.conf
```

**Step-2**: Add the following rules below

```
<Location /chat>
ProxyPass http://127.0.0.1:8001
ProxyPassReverse ws://127.0.0.1:8001
</Location>
```

{% hint style="info" %}
In general port is set to 8001 - can be customized and make sure that env's 'SOCKET\_PORT' number and Proxy's port number are same.
{% endhint %}

#### [<mark style="color:blue;">**Setup an API (Step By Step)**</mark>](#setup-an-api-step-by-step)

For setting up the API, you need to execute the following steps:

* Installing an extension&#x20;
* Run the application&#x20;
* Make the build

**Step -1 : Installing an extension**&#x20;

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in <mark style="color:green;">**"**</mark> <mark style="color:green;">**Admin-and-vendor-chat-addon.zip".**</mark> Extract the zip file, open api folder and open addon folder within that and copy the content of addon folder into the specified path

&#x20;                                      **Path - \<PROJECT\_ROOT>/addon**

**Step-2 : Run the application**

After you have completed the installation of the above mentioned steps, you can run the application and also view the changes.

```
$ npm start serve
```

Once you execute the above command, add-on file will get integrated into the backend API.

**Step-3 : Make the build**

These are the steps that need to be followed for generating the build.

To run the below command

```
 $ npm run build
```

Then latest built files can be deployed into the server.

## Admin Setup

&#x20;These are the steps that need to be executed for installation of the extension.

* Installing an extension
* Update the configuration
* Module Detail
* Run the application
* Make the build

**Step-1 : Installing an extension**                &#x20;

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in "<mark style="color:green;">**chat.addOn.zip**</mark>".&#x20;

Extract the zip file and copy the content of **admin/add-ons** folder into the specified path

&#x20;                                   **Path -  admin/add-ons**

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.&#x20;

```
npm install socket.io-client@4.6.1

```

```
npm install uuidv4@6.2.13

```

1. Add these component name below the file <mark style="color:green;">**admin.module.ts**</mark>

Inside the <mark style="color:green;">**/src/theme/default/admin/admin.module.ts**</mark>&#x20;

```
import { ChatconversationComponent } from '../../../../add-ons/chat/chatconversation/chatconversation.component';

```

**declarations: \[**

&#x20;   **ChatconversationComponent**

**]**

**Step 3 :** Change the routing fil&#x65;**(**<mark style="color:green;">**admin-routing.module.ts**</mark>**)**

Inside the <mark style="color:green;">**src/theme/default/admin/admin-routing.module.ts**</mark>

&#x20; If the point one already exists in your file, skip point one

1. Import below line

```
import * as chatRoutes from'../../../../../../../add-ons/chat/chat.routing';

```

2. Add these routes below the appRoutes array

```
appRoutes[0].children?.push(chatRoutes[0]);

```

For setting up the tab add this line in

<mark style="color:green;">**ssrc/theme/default/admin/shared/components/profile-bar/profile.bar.component.html**</mark>

**Below line no=29**

\<li \*ngIf="isShowChat">

\<button class="chats" \[routerLink]="\['/chatconversation']"> \<img src="assets/imgs/chats.svg" alt="" > \<span>{{getCount()}}\</span> \</button>

&#x20;\</li>

**Step 4 : Run the application**

After you have integrated the chat Module into Spurtcommerce, you can use the following command to run the application.&#x20;

```
 npm run large-serve

```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.&#x20;

\
**Step 5 :** Make the build

To run the below command

```
 npm run large-build

```

Then the latest built files can be deployed into the server.

\
&#x20;Vendor Setup
------------------

These are the steps that need to be followed to do the front end vendor setup.&#x20;

* &#x20;Installing an extension
* Update the configuration
* Module Detail
* Run the application
* Make the build

**Step 1 :** Installing an extension

Usually spurcommerce comes packed in a zip, whose name ends in "<mark style="color:green;">**chat-addOn.zip**</mark>".&#x20;

Extract the zip file and copy the content of <mark style="color:green;">**vendor/add-ons**</mark> folder into the specified path

&#x20;                                                      **Path -  vendor/add-ons**

**Step 2 :** Update the configuration

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.&#x20;

```
npm install socket.io-client@4.6.1

```

```
npm install uuidv4@6.2.13

```

**Step 3 :** Module Detail

Routing

&#x20;     In <mark style="color:green;">**/src/app/app-routing.module.ts**</mark>

1. &#x20;Import below line

```
import { ChatconversationComponent } from '../../add-ons/chat/chatconversation/chatconversation.component';

```

&#x20; 2\. Add these routes below the Routes array

**{**&#x20;

**path: 'chatconversation',**&#x20;

**component: ChatconversationComponent,**&#x20;

**}**

Add this line to keep the header tab&#x20;

<mark style="color:green;">**/src/app/default/shared/components/sidebar/sidebar.component.html**</mark>

**Below line no=61**

&#x20;\<li>&#x20;

\<button class="chats" (click)="chatconversation()"> \<img src="assets/imgs/chats.svg" alt=""> \</button>

&#x20;\</li>

**Step 4 :** Run the application

After you have integrated the chat Module into Spurtcommerce, you can use the following command to run the application.

```
 ng serve

```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.&#x20;

**Step 5 :** Make the build

To run the below command

```
 ng build --prod

```

Then the latest built files can be deployed into the server.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spurtcommerce.com/addons/b2b-related-addons/admin-and-vendor-chat-addon.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
