chatbot-for-SubSpace1

Nhost + Hasura + n8n + OpenRouter – Chatbot App (GraphQL-only)

This is a complete assessment-ready template:

1) Prerequisites

2) Database & Permissions

Run SQL in Hasura → Data → SQL:

Hasura Permissions (role: user)

Tip: In Hasura Insert Preset for chats.user_id, set x-hasura-user-id so clients don’t send user_id.

3) Hasura Action: sendMessage

Create Action in Console:

4) n8n Workflow

Import n8n/chatbot-workflow.json and set env vars in n8n:

Flow:

  1. Validate chat_id belongs to caller (compare x-hasura-user-id with chat.user_id)
  2. Insert user message
  3. Call OpenRouter
  4. Insert bot message
  5. Return bot message payload to Action

5) Frontend Setup

cd frontend
npm i
# Create .env.local with your values
echo "VITE_NHOST_SUBDOMAIN=your-subdomain
VITE_NHOST_REGION=ap-south-1
VITE_HASURA_GRAPHQL_URL=https://<subdomain>.nhost.run/v1/graphql
VITE_HASURA_GRAPHQL_WS=wss://<subdomain>.nhost.run/v1/graphql
VITE_HASURA_ACTION_SENDMESSAGE=sendMessage" > .env.local

npm run dev

6) Deploy to Netlify

7) Demo Steps

  1. Sign up with email/password in the app
  2. Create a new chat (left panel)
  3. Open the chat and send a message
  4. Your message appears instantly (saved via GraphQL). The Action triggers n8n, which calls OpenRouter, saves the bot reply, and you see it live via subscription.

8) Submission Format

Name: Your Name
Contact: 9xxxxxxxxx
Deployed: https://.netlify.app/

9) Quick GitHub Push

git init
git add .
git commit -m "feat: nhost/hasura/n8n/openrouter chatbot"
git branch -M main
git remote add origin https://github.com/<you>/chatbot-app.git
git push -u origin main

10) One-command Push (prelinked)

Run ONE command from the project folder:

macOS/Linux

bash push.sh

Windows (PowerShell or CMD)

push.bat

It will push to: https://github.com/Chandu207-cmd/chatbot-app.git