Skip to content

hemant-i7/ContentPulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ContentPulse πŸš€

AI-Powered Chatbot Platform for Contentstack Integration

ContentPulse is a plug-and-play chatbot platform that seamlessly integrates with Contentstack CMS and leverages advanced Large Language Models (LLMs) like Groq and OpenAI to deliver intelligent, context-aware responses based on your content.

Live Demo & Resources

🎯 Problem Statement

Create a chatbot that:

  • Integrates with Contentstack to fetch dynamic content
  • Uses LLMs (Groq/OpenAI) for intelligent responses
  • Can be easily embedded on any website
  • Provides real-time content-based answers to user queries

✨ Features

πŸ†• OAuth Authentication (New!)

  • πŸ” Secure Contentstack Integration: OAuth 2.0 authentication with Contentstack
  • πŸ“š Multi-Stack Support: Users can select from their available Contentstack stacks
  • 🎯 Personalized Responses: Chatbot serves content from user's selected stack
  • πŸ”„ Dynamic Stack Switching: Change active stack without re-authentication

Core Functionality

  • πŸ”— Contentstack Integration: Fetch products, articles, services, and any content type
  • πŸ€– AI-Powered Responses: Intelligent answers using Groq and OpenAI APIs
  • πŸ“± Responsive Design: Works perfectly on desktop and mobile
  • πŸ”Œ Plug & Play: Easy integration with any website
  • 🎨 Customizable UI: Light/dark themes and configurable appearance
  • πŸ’¬ Real-time Chat: Instant responses with typing indicators
  • πŸ“Š Session Management: Maintain conversation context
  • πŸ›‘οΈ Error Handling: Graceful fallbacks when APIs are unavailable

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚   Frontend      │───▢│   Backend       │───▢│  Contentstack   β”‚
β”‚   (Next.js)     β”‚    β”‚   (NestJS)      β”‚    β”‚     CMS         β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚                 β”‚
                       β”‚   LLM APIs      β”‚
                       β”‚ (Groq/OpenAI)   β”‚
                       β”‚                 β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Contentstack account and API credentials
  • Groq API key or OpenAI API key

Installation

  1. Clone the repository

    git clone https://github.com/your-username/ContentPulse.git
    cd ContentPulse
  2. Install dependencies

    npm install
  3. Set up environment variables

    Backend configuration:

    cd apps/backend
    cp .env.example .env

    Edit apps/backend/.env with your credentials:

    PORT=8000
    CONTENTSTACK_API_KEY=your_api_key
    CONTENTSTACK_ACCESS_TOKEN=your_access_token
    CONTENTSTACK_ENVIRONMENT=development
    GROQ_API_KEY=your_groq_key
    OPENAI_API_KEY=your_openai_key

    Frontend configuration:

    cd ../frontend
    cp .env.example .env.local

    Edit apps/frontend/.env.local:

    NEXT_PUBLIC_API_URL=http://localhost:8000
  4. Start the development servers

    Using Turborepo (recommended):

    npm run dev

    Or start individually:

    # Terminal 1 - Backend
    cd apps/backend
    npm run dev
    
    # Terminal 2 - Frontend
    cd apps/frontend
    npm run dev
  5. Open your browser

πŸ” OAuth Integration Setup

New! ContentPulse now supports Contentstack OAuth authentication for secure, personalized chatbot experiences.

Quick OAuth Setup

  1. Create OAuth App in Contentstack:

    • Go to Contentstack Developer Settings
    • Create new OAuth App with callback URL: http://localhost:8000/auth/contentstack/callback
    • Copy Client ID and Client Secret
  2. Update Backend Environment:

    # Add to apps/backend/.env
    CONTENTSTACK_CLIENT_ID=your-client-id
    CONTENTSTACK_CLIENT_SECRET=your-client-secret
    CONTENTSTACK_CALLBACK_URL=http://localhost:8000/auth/contentstack/callback
    JWT_SECRET=your-secure-jwt-secret
    FRONTEND_URL=http://localhost:3000
  3. Install Additional Dependencies (if not already done):

    cd apps/backend
    npm install
  4. Test OAuth Flow:

    • Visit http://localhost:3000
    • Click "Login with Contentstack"
    • Complete OAuth flow
    • Select your Contentstack stack
    • Start chatting with personalized content!

πŸ“š For detailed setup instructions, see OAUTH_SETUP.md

πŸ”§ Configuration

Contentstack Setup

  1. Create Content Types in your Contentstack space:

    • products (with fields: title, description, price, category)
    • articles (with fields: title, content, summary)
    • services (with fields: title, description, features)
    • tours (with fields: title, description, duration, price)
  2. Get API Credentials:

    • API Key: Found in Settings > Stack > API Key
    • Access Token: Create in Settings > Tokens
    • Environment: Usually 'development' or 'production'

LLM API Setup

Option 1: Groq (Recommended for speed)

  1. Sign up at https://groq.com
  2. Get your API key from the dashboard
  3. Add to GROQ_API_KEY in your .env file

Option 2: OpenAI

  1. Sign up at https://openai.com
  2. Get your API key from the dashboard
  3. Add to OPENAI_API_KEY in your .env file

πŸ’» Usage

Basic Integration

import Chatbot from '@/components/Chatbot';

function MyWebsite() {
  return (
    <div>
      <h1>My Website</h1>
      {/* Your content */}
      
      <Chatbot 
        theme="light"
        height="400px"
        welcomeMessage="Hi! How can I help you today?"
        apiBaseUrl="http://localhost:8000"
      />
    </div>
  );
}

Advanced Configuration

<Chatbot 
  theme="dark"
  height="500px"
  placeholder="Ask me about our products..."
  welcomeMessage="Welcome! I can help you find products, articles, and services."
  apiBaseUrl="https://your-api.com"
/>

API Endpoints

  • POST /api/chat - Send chat messages
  • GET /api/chat/health - Health check
  • GET /api/chat/content-types - Get available content types
  • POST /api/chat/search - Search specific content

πŸ§ͺ Testing

Test the Chatbot

Try these example queries:

  • "Show me your products"
  • "What services do you offer?"
  • "Find articles about technology"
  • "I'm looking for tours under $500"
  • "Help me find information about..."

Health Check

curl http://localhost:8000/api/chat/health

Manual API Testing

curl -X POST http://localhost:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"query": "Show me your products"}'

πŸ“¦ Project Structure

ContentPulse/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ backend/                 # NestJS API server
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot/        # Chatbot module
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot.controller.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot.service.ts
β”‚   β”‚   β”‚   β”‚   └── chatbot.module.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ app.module.ts
β”‚   β”‚   β”‚   └── main.ts
β”‚   β”‚   └── .env.example
β”‚   └── frontend/               # Next.js web app
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ app/
β”‚       β”‚   └── components/
β”‚       β”‚       └── Chatbot.tsx
β”‚       └── .env.example
β”œβ”€β”€ packages/
β”‚   └── chatbot-sdk/           # Reusable SDK (future)
β”œβ”€β”€ package.json
β”œβ”€β”€ turbo.json
└── README.md

πŸš€ Deployment

Live Deployment

Production URL: https://contentpulse-contentpulse-contenpulse.eu-contentstackapps.com/

The application is currently deployed and running live! You can test all features including:

  • OAuth authentication with Contentstack
  • AI-powered chat responses
  • Real-time content integration
  • Responsive design across devices

Deployment Options

Frontend (Vercel)

  1. Push to GitHub
  2. Connect to Vercel
  3. Set environment variables in Vercel dashboard
  4. Deploy

Backend (Railway/Heroku)

  1. Railway:

    railway login
    railway init
    railway add
    railway deploy
  2. Heroku:

    heroku create your-app-name
    heroku config:set CONTENTSTACK_API_KEY=your_key
    heroku config:set GROQ_API_KEY=your_key
    git push heroku main

🎨 Customization

Theming

The chatbot supports light and dark themes:

<Chatbot theme="dark" />  // or "light"

Custom Styling

Override CSS classes for complete customization:

.chatbot-container {
  /* Your custom styles */
}

.chatbot-message {
  /* Message styling */
}

Content Types

Add new content types by:

  1. Creating them in Contentstack
  2. Adding them to determineContentType() in chatbot.service.ts
  3. Testing with queries

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if needed
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License.

πŸ†˜ Support

If you encounter any issues:

  1. Check the Issues page
  2. Create a new issue with:
    • Environment details
    • Error messages
    • Steps to reproduce

🎯 Roadmap

  • Multi-language support
  • Advanced content filtering
  • Analytics dashboard
  • Voice input support
  • Integration with more CMS platforms
  • Custom webhook support
  • Advanced conversation flows

Built with ❀️ for the developer community

ContentPulse

A modern monorepo for ContentPulse applications, built with Next.js (frontend), NestJS (backend), and a reusable chatbot SDK.

πŸ—οΈ Project Structure

ContentPulse/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ frontend/          # Next.js application
β”‚   └── backend/           # NestJS API server
β”œβ”€β”€ packages/
β”‚   └── chatbot-sdk/       # Reusable chatbot SDK
β”œβ”€β”€ package.json           # Root workspace configuration
β”œβ”€β”€ turbo.json            # Turborepo configuration
└── .gitignore            # Git ignore rules

πŸš€ Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd ContentPulse
  1. Install dependencies for all packages:
npm install

Development

Start all applications in development mode:

npm run dev

This will start:

  • Frontend (Next.js) on http://localhost:3000
  • Backend (NestJS) on http://localhost:8000

Build

Build all applications:

npm run build

Available Scripts

  • npm run dev - Start all apps in development mode
  • npm run build - Build all applications
  • npm run start - Start all applications in production mode
  • npm run lint - Lint all packages
  • npm run test - Run tests for all packages

πŸ“¦ Packages

Frontend (apps/frontend)

  • Tech Stack: Next.js, TypeScript, Tailwind CSS
  • Dependencies: axios, @tanstack/react-query
  • Port: 3000

Backend (apps/backend)

  • Tech Stack: NestJS, TypeScript
  • Dependencies: axios
  • Port: 8000

Chatbot SDK (packages/chatbot-sdk)

  • Tech Stack: TypeScript
  • Purpose: Reusable chatbot functionality across applications
  • Export: ES modules with TypeScript definitions

πŸ› οΈ Tech Stack

  • Monorepo Management: Turborepo + npm workspaces
  • Frontend: Next.js 15 with TypeScript and Tailwind CSS
  • Backend: NestJS with TypeScript
  • Package Manager: npm
  • Build System: Turborepo for parallel builds and caching

πŸ”§ Configuration

Turborepo

The project uses Turborepo for efficient build caching and parallel execution. Configuration is in turbo.json.

Workspaces

npm workspaces are configured in the root package.json to manage dependencies across all packages.

πŸ“ Development Guidelines

  1. Code Style: Follow TypeScript and ESLint rules
  2. Commits: Use conventional commit messages
  3. Dependencies: Add shared dependencies at the workspace level when possible

πŸš€ Deployment

Each application can be deployed independently:

  • Frontend: Deploy to Vercel, Netlify, or any static hosting
  • Backend: Deploy to Railway, Render, or any Node.js hosting
  • SDK: Publish to npm registry for reuse

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

πŸ“„ License

[Add your license here]

About

Resources

Stars

5 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors