Skip to content

Code4Bharat-2025/team16

Repository files navigation

BrainyBuds

An exciting personalised learning adventure experience to embark upon journey of knowledge discovery to create fun and interactive quizzes based on child's unique interest and learning style

Presentation reference

Demo

Chat Bot API

A Node.js backend service for handling chatbot interactions using SwiftChat's bot platform, with Redis and PostgreSQL integration.

⚙️ Local Setup Instructions

Follow these steps to set up the repository on your local machine:

1. Install Required Services

2. Setup SwiftChat Bot Credentials

You will need the following details from your SwiftChat bot configuration:

  • Bot ID
  • API Key
  • API URL

These values will be used to configure your environment.

3. Create Environment Configuration

  1. Review the file template.env.
  2. Create a .env file in the root directory with the following structure:
BOT_UUID=<bot_id>
KLUSTER_API_URL=https://put-url-here/api
KLUSTER_API_TOKEN=<token>

# Redis configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# PostgreSQL configuration
PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=yourpassword
PG_DATABASE=chat_bot_db

# Application
PORT=3000

4. Install Dependencies

Run the following command to install all Node.js dependencies:

npm install

5. Seed the Database

Ensure PostgreSQL and Redis services are running. Then seed the database:

npm run seed

This will create the necessary tables and populate them with dummy data.

✅ Setup Complete

📹 Demo Video

▶️ Watch the demo

Swiftchat postman

📋 View Postman Documentation

🚀 Running the Application

Development Mode

To start the app with live-reloading:

npm run dev

Production Mode

To start the app in production:

npm start

Entry Point

The main entry file for the application is: app.js

🔄 Testing the App Locally

Once the app is running on the desired port:

  • Use the SwiftChat Bot API to send test messages to the backend.

During local testing:

  • The bot will send messages to the SwiftChat frontend.
  • Messages from frontend → backend will not work directly.

To simulate this flow locally, use Postman or any other API testing tool along with the shared Postman collection.

🌐 Connecting Frontend and Backend via Localhost (NGROK)

⚠️ Disclaimer: NGROK's free plan has a limited number of requests and may become unreliable after exceeding those limits.

Steps:

  1. Download NGROK from: https://ngrok.com/download

  2. Start your local backend server:

npm run dev
  1. Open an NGROK tunnel by running:
ngrok http <PORT>

(Replace <PORT> with the port your backend is running on.)

  1. Open the NGROK inspector to view logs and details:
http://localhost:4040/inspect/http
  1. Copy the public NGROK URL (e.g., https://xyz.ngrok.io).

  2. Using the SwiftChat Platform API:

    • Call the get-webhook-url endpoint to check the current webhook.
    • Use the update-webhook-url endpoint to update it to the NGROK URL.

Now your frontend is connected to your backend running locally via NGROK. You can interact with buttons and send messages directly from SwiftChat frontend to your Node.js backend.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors