๐Ÿ›๏ธ ThunderBeans GPT + Email Report Automation

April 20, 2025 ยท View on GitHub

CHALLENGE Program Banner

๐Ÿ›๏ธ ThunderBeans GPT + Email Report Automation

This project powers an AI-driven, simulation-based policy negotiation game โ€” the ThunderBeans GPT Parliamentary Policy Simulator โ€” and integrates it with a custom Node.js + SendGrid email API that automatically delivers evaluation reports to stakeholders.


๐ŸŽฎ Simulation Purpose

The simulation allows a user to play as a Member of Parliament in the fictional Republic of Bean, engaging in a structured 3-phase process:

  1. Individual Decision-Making โ€“ Create a 14-unit refugee education policy package.
  2. Group Debate โ€“ Negotiate and vote with 4 AI-generated MPs.
  3. Parliamentary Debrief โ€“ Reflect on motivations, trade-offs, and justice.

It focuses on inclusion, budget trade-offs, and social justice โ€” grounded in critical pedagogy and designed as a learning tool for education and policy research.


๐Ÿ“‚ Integration for Facilitator Script or System Module โ€œThis simulation defaults to immersive mode. You may say at any time: โ€˜Speaker, step out of characterโ€™ to ask for system-level insight, or _โ€˜Speaker, resume full roleplayโ€™ to re-enter immersive parliamentary dialogue.โ€

๐Ÿงญ Embedded Toggle Logic (For Facilitators/Engineers) Before launching any phase of the simulation, confirm simulation mode: If facilitator or user says: โ†’ โ€œSpeaker, resume full roleplayโ€ โ†’ Disable developer-facing outputs โ†’ Enable immersive, in-character Speaker responses only โ†’ Continue simulation in user-centric narrative mode If facilitator or user says: โ†’ โ€œSpeaker, step out of characterโ€ โ†’ Pause immersive simulation โ†’ Enable technical explanations and internal simulation logic โ†’ Respond using system-facing documentation and debug-level clarity

๐ŸŽฎ Voice/GUI Interface Integration (Optional): Command Action Taken by System Notes Speaker, resume full roleplay Switch to immersive mode Default state for users Speaker, step out of character Switch to developer/debug mode For testers, developers, facilitators What mode am I in? Respond with current simulation mode status Optional helper command

โš™๏ธ Technical Features

  • ChatGPT Action: Integrates the simulation into ChatGPT as a tool.
  • Node.js Email API: Sends post-simulation reports via SendGrid.
  • Replit Hosting: Deployed with autoscaling & public API endpoint.
  • OpenAPI Schema: Supports structured interaction inside ChatGPT.

๐Ÿ“ฌ Email API Overview

Built using Node.js + Express + @sendgrid/mail:

Endpoint:

POST /send-email

Request Body:

{
  "recipientEmail": "tcvera@asu.edu",
  "reportContent": "Simulation summary + reflection",
  "subject": "Evaluation Report"
}

Response:

  • 200 OK โ†’ "Email sent successfully"
  • 400 Bad Request โ†’ "Missing required fields"
  • 500 Server Error โ†’ "Failed to send email"

๐Ÿ› ๏ธ How to Run Locally

git clone https://github.com/TawandaVera/ThunderBeans.git
cd ThunderBeans
npm install
cp .env.sample .env  # Add your SENDGRID_API_KEY
npm start

Test it:

curl -X POST http://localhost:3000/send-email   -H "Content-Type: application/json"   -d '{"recipientEmail":"you@example.com", "reportContent":"Test content"}'
``$

---

## ๐Ÿง  \text{Simulation} \text{Knowledge} \text{Base}

\text{This} \text{GPT}'\text{s} \text{simulation} \text{logic} \text{is} \text{grounded} \text{in} \text{the} \text{following} \text{documents}:

- ๐Ÿ›๏ธ \text{Republic} \text{of} \text{Bean} \text{scenario} (\text{socio}-\text{political} \text{context}, \text{refugee} \text{crisis})
- ๐ŸŽ“ 7 \text{Education} \text{Policy} \text{Areas}  \times  3 \text{Options} \text{Each} (\text{see} \text{PDF}/\text{markdown} \text{in} $/docs`)
- ๐Ÿ’ฐ Strict 14-unit Budget System
- ๐Ÿง  MP Simulation Logic (Hidden profiles, adaptive debate)
- ๐Ÿ“„ Evaluation Report Guidelines (auto-emailed post-simulation)
- ๐Ÿ’ฌ Debrief Reflection Prompts (justice, inclusion, power)

> Full source docs in [`/docs/`](./docs)

---

## ๐Ÿ“‚ Repo Structure

/ThunderBeans |-- index.js # Email API Server |-- package.json |-- .env.sample |-- README.md |-- openapi.json # For ChatGPT Action Integration |-- /docs # Simulation logic + policy files


---

## โœจ Future Additions

- ๐ŸŽค Voice input/output for MPs
- ๐Ÿ” Persistent database for multiple session tracking
- ๐Ÿ”’ Auth protection for the email API
- ๐Ÿ“Š Data visualization of policy trends

---

## ๐Ÿ‘ฅ Maintainers & Submission

- Created for the AI CHALLENGE Hackathon
- Report emails go to: `aturan@asu.edu`, `JANEL.WHITE@asu.edu`

--- 

## ๐Ÿ“˜ License

MIT โ€” free for ethical educational use. Credit required for remix/reuse.