Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
93 changes: 0 additions & 93 deletions Server setup.txt

This file was deleted.

68 changes: 62 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,68 @@ <h3 class="modal-title">Settings</h3>
<i class="fas fa-exclamation-triangle"></i> Delete All User Data
</button>
</div>
<div class="alert alert-warning mt-3" role="alert">
<i class="fas fa-exclamation-circle"></i> Warning: "Delete All User Data" will permanently remove all your chat history, settings, and preferences.
</div>
</div>
</div>
</div>
<div class="alert alert-warning mt-3" role="alert">
<i class="fas fa-exclamation-circle"></i> Warning: "Delete All User Data" will permanently remove all your chat history, settings, and preferences.
</div>
<hr class="divider" />
<div class="twilio-call-card">
<h4 class="twilio-call-heading">
<i class="fas fa-phone"></i> Unity Phone Call
</h4>
<p class="twilio-call-description">
Configure your Twilio voice bridge server and start a phone call where Unity speaks using Pollinations.
</p>
<div class="form-group mb-3">
<label for="twilio-server-url" class="form-label">Voice bridge URL</label>
<input
type="url"
id="twilio-server-url"
class="form-control"
placeholder="https://your-voice-bridge.example.com"
/>
<div class="form-text">
Provide the HTTPS base URL of the deployed server that exposes the <code>/api/start-call</code> route.
</div>
</div>
<div class="form-group mb-3">
<label for="twilio-phone-number" class="form-label">Phone number (E.164 format)</label>
<input
type="tel"
id="twilio-phone-number"
class="form-control"
placeholder="+15551234567"
/>
</div>
<div class="form-group mb-3">
<label for="twilio-initial-prompt" class="form-label">Initial topic or instructions</label>
<textarea
id="twilio-initial-prompt"
class="form-control"
rows="3"
placeholder="Ask Unity to call me with an update about our project."
></textarea>
</div>
<div class="form-group mb-3">
<label for="twilio-voice-select" class="form-label">Pollinations voice</label>
<select id="twilio-voice-select" class="form-control">
<option value="nova">Nova (default)</option>
<option value="alloy">Alloy</option>
<option value="fable">Fable</option>
<option value="onyx">Onyx</option>
<option value="shimmer">Shimmer</option>
<option value="echo">Echo</option>
</select>
</div>
<div class="d-grid gap-2">
<button id="twilio-start-call-btn" class="btn btn-success">
<i class="fas fa-phone-volume"></i> Call My Phone
</button>
</div>
<div id="twilio-call-status" class="twilio-call-status mt-3" role="status" aria-live="polite"></div>
</div>
</div>
</div>
</div>
<div id="memory-modal" class="modal-backdrop hidden">
<div class="modal-container">
<div class="modal-header">
Expand Down
127 changes: 0 additions & 127 deletions readme.txt

This file was deleted.

Loading