This guide provides instructions to set up and run the following locally:
- ConnectedAI - Web App - Backend Server
- ConnectedAI - Web App - Frontend Server
- ConnectedAI - AI - Backend Server
The backend server handles:
- User authentication (with JWT tokens).
- Guest token generation.
- Chatbot message processing.
- User login with JWT authentication.
- Guest mode support with token issuance.
- API to process chat messages.
- Node.js (v16 or higher)
- NPM or Yarn
.env
file with the following variables:PORT=5001 SECRET_KEY=your_secret_key
- Make sure you have the Service Account private key downloaded as JSON file
serviceAccount.json
To use the Firebase Admin SDK on your own server (or any other Node.js environment), use a service account. Go to IAM & admin > Service accounts in the Google Cloud console. Generate a new private key and save the JSON file.
- The csv file with the Users data to be loaded into the Collection
-
Go to the
db-load
foldercd 8_code/apps/api-server/db-load
-
install dependencies
npm install
-
Run the upload
node index.js
-
The records will be uploaded to the Firestore
users
collection.
-
Clone the repository:
git clone <repository_url> cd 8_code/apps/api-server
-
Install dependencies:
npm install
-
Start the server:
npm start
By default, the server uses PORT=5001
and the specified SECRET_KEY
.
The React-based frontend allows:
- User login with a username and password.
- Guest mode for interacting with the chatbot without an account.
- A modern and responsive chat interface built with
@chatscope/chat-ui-kit-react
. - JWT token-based authentication for secure API requests.
- Login with username and password.
- Guest mode for non-registered users.
- Responsive chat UI.
- Token-based authentication for requests to the backend.
- Node.js (v16 or higher)
- NPM or Yarn
-
Clone the repository:
git clone <repository_url> cd 8_code/apps/app-ui
-
Install dependencies:
npm install
-
Configure the backend API base URL:
- Open
src/api/apiClient.js
. - Update the
BASE_URL
constant to match your backend server's URL:const BASE_URL = 'http://localhost:5001';
- Open
-
Start the development server:
npm start
-
To build the code for deployment:
npm run build
- Ensure both backend and frontend servers are running to enable full functionality.
- Configure the backend and frontend to communicate using consistent environment variables or configuration files.
To install the necessary dependencies, run:
make init
To start the service, use:
make run
To call the API, execute:
make post
Comment the lines in start_service.py to switch between the agents.
from core.server.main_gemini import app
# from core.server.main_mock import app
main_gemini service is using Gemini model, either the free Google Gemini model or VertexAI.
main_mock service is using the mock model, which is a simple model that returns a fixed response.
You will need to create local/mock_data.py contains the mock output data. i.e.
outputs=[
{"user":"Hello","AI":"How can I help you!"},
{"user":"Hello","AI":"How can I help you 2!"},
{"user":"Hello","AI":"How can I help you 3!"},
]
You will also need a local/local_config.py, use the one in example folder as a template.
/chat
/chat_mock
/chat_free
/chat_graph
/ws/chat
/ws/chat_mock
/ws/chat_free
/ws/chat_graph
{
"chatMessage": "Hello",
"sessionId": "test_session",
"isAuthenticated": true,
"customerId": 123
}
or
{"chatMessage":"Hello","sessionId":"test_session","isAuthenticated":false}
example api response:
{"chatMessage":"Hello","sessionId":"test_session","isAuthenticated":true,"customerId":123,"response":"\n","isCompleted":true}
example websocket request:
{"chatMessage":"Hello","sessionId":"test_session","isAuthenticated":true,"customerId":123,"response":"\n"}
example websocket response as sequence:
{"response":"","isCompleted":false}
{"response":"","isCompleted":false}
{"response":"Hi","isCompleted":false}
{"response":" there! How can I help you today? I can assist with questions about","isCompleted":false}
{"response":" your orders or products.\n","isCompleted":false}
{"chatMessage":"Hello","sessionId":"test_session","isAuthenticated":true,"customerId":123,"response":"\n","isCompleted":true}
Note that JWT tokens are now used to encode and decode all messages. Please refer to convert_jwt_to_chat_item function in ai-backend/core/server/main_server.py for detail.