AI_Chatbot_Code_Challenge(20250723)
Important
I am creating a custom chat app to interact with my clients. The chatbot must be polite, maintain focus on delivering an excellent customer experience, and provide accurate, specific information about the chosen product. Each team should select a different product for their chatbot to support (e.g., a SaaS analytics tool, an e-commerce platform, or a fleet-management system).
The technical details are into this README.md
Watch the AI Chatbot in action processing financial queries with authentication and real-time data retrieval
- As Stock Market User I need to know the last "United States Indices":
{"username":"Admin","question":"What are the United States Indices?"}- As Stock Market User I need to know the last "Most Active Stocks":
{"username":"Admin","question":"What are the Most Active Stocks?"}- As Stock Market User I need to know the last "Top Gainers":
{"username":"Admin","question":"What are the Top Gainers?"}- As Stock Market User I need to know the last "United States Sector Summary"
{"username":"Admin","question":"What is the list Sector Summary?"}The site to do this request and scraping is:
- Project will use
Node.js/Express- This will be the directory layout:
- Commit to git using the tree definiction as:
feature: This feature branch isolates the new code or changes related to that specific functionality.hotfix: To isolate the fixes from the main (master) development line.Objective: Secure your chatbot with user/password login.
The URL of the API, is this:
https://webapp-ai-chatbot-cdg8a7cpetckeja2.westeurope-01.azurewebsites.net/
- The user creation must be with the API using:
» Method:POST
» URL:api/auth/register
» Body:{"username":"NewName", "password": "abcd1234"}- The user login to get the token:
» Method:POST
» URL:api/auth/login
» Body:{"username":"NewName", "password": "abcd1234"}- The check of validation (Optional):
» Method:GET
» URL:api/chat/can-access
» Body:{"username":"NewName"}
» Header:x-auth-token=<token>- Chat with Chatbot:
» Method:POST
» URL:api/chat
» Body:{"username":"NewName","question":"What are the Most Active Stocks?"}
» Header:x-auth-token=<token>Objective: Implement the
/chatendpoint and integrate with an LLM APIAfter the user validation with the token, those are the steps:
- Scraping and text extraction
For of FINANCE_URLS and fetchAndExtractText()- Chunking
ChunkText();- Embeddings of the chunks
embedChunks();- Vectorizing in Pinecone
upsertEmbeddings();- Embedding of the question and search
embedChunks([q]) and searchSimilarChunks()- OpenAI Validation and Improvement
validateAndImproveChunks() - Validates and improves chunk quality- OpenAI Response Generation
generateResponseFromChunks() - Generates coherent responses using OpenAIObjective: Augment replies with product context.
Objective: Generate and run unit/integration tests.
Implementation: Comprehensive Jest test suite with 45+ tests covering authentication flows, LLM integration, and retrieval logic. All external services (OpenAI, Pinecone, web scraping) are properly mocked for fast, reliable testing.
Usage:
npm install npm test # Run all tests npm run test:coverage # Run with coverage report npm run test:watch # Development watch mode📖 Detailed Testing Documentation - Complete guide to the test suite, coverage details, and test scenarios.
Objective: Automate build, test, and deploy.
Objective: Deploy your containerized chatbot to the cloud.
The project includes a comprehensive automated testing suite:
- Unit Tests: Controllers, middleware, and services
- Integration Tests: Complete API endpoints with authentication
- Mocked Services: OpenAI, Pinecone, and web scraping services
- Coverage: 80%+ lines, functions, branches, and statements
- CI/CD Ready: No external dependencies for testing
Quick Start:
npm testFor detailed testing information, see Testing Documentation.
- Swap JWT for OAuth2 or SSO integration.
- Implement a front-end chat widget that handles login and chat sessions.
- Add observability: logs, metrics, and a health check endpoint.
- Delivery Date: August 1 of 2025
- Deliverable: Code repository url, chatbot repository
- Deliver to: latinamericalearningdevelopment@perficient.com


