π Project Overview
This project is a university-focused chatbot built for the TIU Impact Hub β a student-led innovation and leadership community at Tokyo International University in Japan.
The chatbot is powered by Gemini AI, and integrates Permit.io to protect sensitive actions (like mass emailing) through fine-grained, externalized access control.
π Why Permit.io?
Instead of hardcoding logic like if user.role === 'admin'
, I used Permit.io for:
- β Role-based access (admin vs visitor)
- β Externalized policy enforcement
- β A future-ready structure for more scalable AI commands (e.g., Discord posting, Slack messages)
π» Live App or Local Testing Instructions
This app currently runs locally (not yet deployed). You can easily test it with:
Backend
cd server
npm install
node server.js
** Frontend**
cd client
npm install
npm run dev
Test Accounts
Please use the following credentials for testing:
Admin
userId: admin
role: admin
password: 2025DEVChallenge
Visitor
userId: newuser
role: visitor
password: 2025DEVChallenge
These values are passed to the backend in the request body and evaluated by Permit.io to allow or block AI actions.
AI Features
Gemini AI chatbot: Responds only to TIU-related questions
/send_email command: Sends emails to all members β admin-only
Visitors are politely denied if they try restricted actions
Key Code Samples
Access Control Enforcement
const isAllowed = await checkPermission(userId, "send_email_to_members", role);
if (!isAllowed) {
return res.json({ reply: "β You are not allowed to send emails." });
}
Gemini Prompt Injection
const systemPrompt = `
You are the official chatbot of TIU Impact Hub, a student-led innovation community...
Only answer questions related to TIU Impact Hub. Refuse politely otherwise.
`;
π GitHub Repo
π https://github.com/Coderanger08/TIUIH_chatbot.git
** Reflection**
Using Permit.io made it so easy to manage access control. Itβs clean, centralized, and scalable β especially for future plans like posting to Discord or creating AI dashboards with more roles (mentor, manager, etc.).
No more spaghetti-role-checks in code β just clean policy logic.
Final Thoughts
Thanks to the Permit.io team and DEV for this opportunity!
I had fun building this and learned how to combine:
Gemini AI (text generation)
Role-based access (externalized)
Real-world functionality (email)
Top comments (0)