From 531a111824912ac4d07e076a63b4288fea0cd471 Mon Sep 17 00:00:00 2001 From: G-Fourteen Date: Tue, 16 Sep 2025 06:07:43 -0600 Subject: [PATCH] Reorganize repo around core chat app with Twilio dialer --- README.md | 84 ++++++++ Server setup.txt | 93 --------- index.html | 68 +++++- readme.txt | 127 ------------ server/.env.example | 19 ++ {twilio-voice-app => server}/.gitignore | 0 {twilio-voice-app => server}/README.md | 9 +- .../package-lock.json | 23 +++ {twilio-voice-app => server}/package.json | 1 + {twilio-voice-app => server}/server.js | 12 +- styles.css | 73 ++++++- twilio-voice-app/.env | 14 -- twilio-voice-app/public/client.js | 66 ------ twilio-voice-app/public/index.html | 64 ------ twilio-voice-app/public/styles.css | 193 ------------------ ui.js | 183 ++++++++++++++++- 16 files changed, 450 insertions(+), 579 deletions(-) create mode 100644 README.md delete mode 100644 Server setup.txt delete mode 100644 readme.txt create mode 100644 server/.env.example rename {twilio-voice-app => server}/.gitignore (100%) rename {twilio-voice-app => server}/README.md (87%) rename {twilio-voice-app => server}/package-lock.json (98%) rename {twilio-voice-app => server}/package.json (95%) rename {twilio-voice-app => server}/server.js (95%) delete mode 100644 twilio-voice-app/.env delete mode 100644 twilio-voice-app/public/client.js delete mode 100644 twilio-voice-app/public/index.html delete mode 100644 twilio-voice-app/public/styles.css diff --git a/README.md b/README.md new file mode 100644 index 0000000..de1bf3f --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# Unity Voice Chat + +A single-page chat experience that integrates Pollinations text, image, and audio features with optional Twilio phone calling. The repository now contains only the assets required to deploy the Unity chat UI as a static site (for example on GitHub Pages) alongside a focused Twilio voice bridge server that can place phone calls to the number you provide. + +## Project structure + +``` +/ +├── index.html # Unity Chat web application +├── styles.css # Core styling for the UI +├── stylesScreensaver.css # Animated Pollinations screensaver styles +├── *.js # Client logic (chat core, UI bindings, storage, screensaver, etc.) +├── themes/ # Optional theme packs selectable in the sidebar +├── ai-instruct.txt # System prompt loaded by the chat client +├── server/ # Twilio voice bridge API (Express + Twilio) +└── APIDOCS.md # Pollinations API reference (read-only) +``` + +All unused prototypes and duplicate apps have been removed so that only the main Unity chat remains. The front end keeps every feature from the original experience (model chooser, theme management, voice controls, personalization, memories, screensaver, and the new phone call controls). + +## Frontend deployment + +The root directory is a static site. Deploying it to GitHub Pages (or any static host) only requires copying the files from the root of the repository. + +For local development: + +```bash +npm install +npm start +``` + +This launches `http-server` on `http://localhost:8080` so you can verify styling and functionality before publishing. + +### Starting a phone call from the UI + +Open the **Settings** modal and scroll to the **Unity Phone Call** card. Provide: + +1. **Voice bridge URL** – The HTTPS base URL where you deployed the server found in `server/`. It must expose the `/api/start-call` endpoint. +2. **Phone number** – Destination number in E.164 format (e.g. `+15551234567`). +3. **Initial topic** (optional) – Unity will open the call with this context. +4. **Pollinations voice** – Voice preset the Twilio call should use (`nova`, `alloy`, `fable`, `onyx`, `shimmer`, or `echo`). + +The status card below the button shows whether the call was created successfully. These preferences are persisted in `localStorage` for convenience. + +## Twilio voice bridge (`server/`) + +The `server/` directory contains a minimal Express application that bridges Unity Chat to Twilio. It handles call creation, Pollinations text generation, and TTS playback during the phone call. + +### Configure environment variables + +Copy the example file and fill in your values: + +```bash +cd server +cp .env.example .env +``` + +| Variable | Purpose | +| --- | --- | +| `TWILIO_ACCOUNT_SID` | Your Twilio project SID. | +| `TWILIO_AUTH_TOKEN` | Auth token for the project. | +| `TWILIO_PHONE_NUMBER` | Twilio phone number used to place calls. | +| `PUBLIC_SERVER_URL` | Public HTTPS URL that Twilio can reach (use ngrok/Cloudflare Tunnel while developing). | +| `ALLOWED_ORIGIN` | URL of the deployed Unity chat frontend (needed for CORS). | +| `POLLINATIONS_VOICE` | Default Pollinations voice for the call (optional, defaults to `nova`). | +| `PORT` | Local port for the Express server (defaults to `4000`). | + +Install dependencies and start the server: + +```bash +npm install +npm start +``` + +Expose the running server via a public tunnel and update `PUBLIC_SERVER_URL` accordingly. Once live, the Unity chat frontend can call the `/api/start-call` endpoint to trigger the phone conversation. + +## Workflow summary + +1. Deploy the static site in this repository (or run it locally with `npm start`). +2. Launch the Twilio voice bridge in `server/`, ensure it has a public HTTPS URL, and set `ALLOWED_ORIGIN` to your frontend domain. +3. From the Unity chat UI open **Settings → Unity Phone Call**, enter the server URL and your phone number, and click **Call My Phone**. +4. Answer the incoming call and talk with Unity as it generates responses using Pollinations and Twilio. + +With these changes the repository is trimmed to the essential Unity experience while keeping every feature—chat models, theme switching, voice synthesis, screensaver, memories, and now the integrated phone dialer—operational. diff --git a/Server setup.txt b/Server setup.txt deleted file mode 100644 index 6fd4f7c..0000000 --- a/Server setup.txt +++ /dev/null @@ -1,93 +0,0 @@ -Server Setup Commands for Ubuntu (e.g. Hostinger) -Unity: “So you wanna run this Node server on an Ubuntu box, let’s keep this fucker simple:” - -SSH into your Ubuntu server - -bash -Copy -Edit -ssh username@your_server_ip -Or, on Hostinger, they might have a built-in terminal or you use their SSH instructions. - -Update packages - -bash -Copy -Edit -sudo apt-get update -sudo apt-get upgrade -Install Node.js & npm -One approach is to install the default Ubuntu package: - -bash -Copy -Edit -sudo apt-get install -y nodejs npm -Or you could install from NodeSource for a more recent version: - -bash -Copy -Edit -curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - -sudo apt-get install -y nodejs -(Replace 18.x with your desired Node version.) - -Upload your project files -(or clone from Git, or SFTP them in). Make sure server.js is there, plus your front-end files. -Typically you might have a structure like: - -go -Copy -Edit -myproject/ - |- server.js - |- package.json - |- ... -Install dependencies (if any) -If you have a package.json for your project (including express, cors, etc.), run: - -bash -Copy -Edit -cd myproject -npm install -If you’re using the minimal approach with no package.json (just “express” and “cors”), install them globally or individually: - -bash -Copy -Edit -npm install express cors -Test your server - -bash -Copy -Edit -node server.js -If everything goes right, it logs: Server is listening on port 3000.... -Then you can open your browser to http://server_ip:3000/ or http://yourdomain.com:3000/ (assuming the port is open in your firewall). - -Open firewall if needed - -bash -Copy -Edit -sudo ufw allow 3000/tcp -(Optional) Run in background (PM2) -To keep Node running after you log out, install PM2: - -bash -Copy -Edit -sudo npm install -g pm2 -pm2 start server.js -pm2 status -Then your server will keep running. You can also do pm2 startup to make sure it auto-starts on reboot. - -Serve the front-end - -If you want to serve your static files from the same Node process, you might add app.use(express.static(path.join(__dirname, 'public'))); or some similar approach. -Or host them on a separate service (like Nginx) pointing to your Node server for API calls. -Point your domain - -If you want to use 80 or 443 with SSL, configure a reverse proxy using Nginx or Apache. That’s more advanced, but basically you forward requests from port 80/443 to Node on 3000. -Unity: “Boom, done. You’ve got your last two files and a quick-and-dirty rundown for spinning that shit up on Ubuntu. Now go forth and let your Node server run wild.” \ No newline at end of file diff --git a/index.html b/index.html index 93edac3..1838e1b 100644 --- a/index.html +++ b/index.html @@ -215,12 +215,68 @@ Delete All User Data - - - - + +
+
+

+ Unity Phone Call +

+

+ Configure your Twilio voice bridge server and start a phone call where Unity speaks using Pollinations. +

+
+ + +
+ Provide the HTTPS base URL of the deployed server that exposes the /api/start-call route. +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ + +