# Jignesh Patel AI calling: handoff (2026-11-11 18:35 UTC)

Separate project from all Khanna work. Never post or mix it into Khanna profiles or the drip.

## How a call flows
```
POST https://line.dramankhanna.cloud/v1/calls   (OpenLine server, container "openline", internal http://openline:8787)
  -> Samsung Z Flip5 (deviceId phone-7ced660f, sir's Vi SIM) dials the number
  -> patched OpenLine Android app streams call audio (raw 16 kHz PCM) to the bridge
  -> el-bridge (container "el-bridge", ws://el-bridge:8090, code ~/stacks/el-bridge/bridge.py)
  -> ElevenLabs agent websocket (signed URL), sir's cloned voice
```

## Credentials (files only; never paste the values in chat or git)
| What | Where |
|---|---|
| ElevenLabs API key | `~/stacks/jignesh-voice/.elkey` (same key as `ELEVENLABS_API_KEY` in the el-bridge container) |
| OpenLine API key (to place calls) | `~/stacks/openline/admin.cred` → line `OPENLINE_API_KEY=` |
| OpenLine key copy used by the bridge for hangup | `~/stacks/el-bridge/.openline_key` (gitignored) |
| OpenLine server config | `~/stacks/openline/server/.env` (PORT=8787) |

## ElevenLabs
- **Live agent:** `agent_1501m75n5wcyepk87xt0dteyahv1` "IOA Voting Caller (trial1)". The old agent `agent_7901m74kjvksesqt5t9s4gsn6zmn` is unused.
- **Voice:** sir's instant clone `2JMt1VYhMZClhQizwJUn`. Sir's consent is in `consent.json`.
- **Knowledge base:** `NtX5PUuue2iOrRgo5lsl` "campaign KB v4 (confirmed)". Source: `Jignesh_Patel_KB_v4.md`.
- **Settings owner approved as "perfect":**
  - LLM: gemini-3.5-flash, reasoning_effort minimal
  - TTS: eleven_v3_conversational, stability 0.5, similarity 0.65, speed 0.92, expressive OFF
  - Turn-taking: eager, turn_timeout 3 s, soft filler off
  - Interruptions: full (ignore-terms cleared; backup in session scratchpad); first message cannot be interrupted
- **First message:** `Hello {{name}} sir, main Professor Doctor Jignesh Patel, Surat Gujarat se bol raha hoon.`
  - The bridge always sends `name` (default "डॉक्टर").
- **Flow (sir's own wording):**
  1. Greeting, then wait.
  2. "Sir ji, main Indian Orthopaedic Association ki Joint Secretary ki post ke liye contest kar raha hoon... Please aapke support ke liye call kiya hai."
  3. On agreement: "Thank you sir." + end_call.
  - "Sir ji" once only. No friends request, no "kaise hain", no "bahut achha" or "din shubh ho". Voting dates in English: "eighteenth to twenty-eighth November".
- **Edit the agent:** `PATCH https://api.elevenlabs.io/v1/convai/agents/<id>` with header `xi-api-key`. Changes go live immediately; no publish needed. Dashboard edits need Publish.
- **Read calls:**
  - `GET /v1/convai/conversations?agent_id=<id>&page_size=1`, then `GET /v1/convai/conversations/<conv_id>` for the transcript and metrics.
  - `.../<conv_id>/audio` for the recording.

## Place a call (copy-paste)
```bash
KEY=$(grep -oP 'OPENLINE_API_KEY=\K\S+' ~/stacks/openline/admin.cred)
curl -s -X POST https://line.dramankhanna.cloud/v1/calls -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
 -d '{"deviceId":"phone-7ced660f","to":"+91XXXXXXXXXX","stream":{"url":"ws://el-bridge:8090/?agent_id=agent_1501m75n5wcyepk87xt0dteyahv1&name=Dr.%20Hardik&ambience=1","format":"raw"}}'
# status:  GET  /v1/calls/<callId>       events: GET /v1/calls/<callId>/events
# hang up: POST /v1/calls/<callId>/hangup
```
**Bridge query parameters:**
- `agent_id` (required)
- `name`: the doctor's spoken name
- `gain`: voice volume, default 0.3
- `ambience=1`: quiet room tone, test only (file `amb_loop.pcm`)
- `amb`: room-tone volume

**What the bridge does:**
- Waits for the goodbye audio to finish playing.
- Then calls OpenLine `/hangup` itself. OpenLine does not hang up when the stream closes, and that caused the "Hello?" at the end of calls.

## Phone side (Samsung Flip5)
- The app is my patched OpenLine build. One UI ignores `enterBackgroundAudioProcessing`, so the app falls back to its own audio bridge.
- **v2 APK** shortens the fallback wait from 1500 ms to 250 ms. It is built but NOT installed yet. Link: https://videos.dramankhanna.cloud/dl-d77db6a74a/OpenLine-samsung-patch-v2.apk
- Source: `~/stacks/openline/android/.../telecom/GatewayInCallService.kt`. Build command: docker `ghcr.io/cirruslabs/android-sdk:35` + openjdk-17 (see the transcript).
- The Flip's mic stays live during AI calls (Samsung ignores setMuted). Keep the Flip in a quiet place.

## Costs
- About 570 ElevenLabs credits per minute; a call costs about 250–430 credits.
- Creator plan: about 363k credits left at 17:15, resets 3 Dec.

## Rules / positions
- Test calls so far: owner 8980822922, sir 98241 14277, Dr Hardik 98797 55544, Dr Sunny 99206 69961, 85116 24442. All are informed testers.
- The owner removed the AI-disclosure line from the opening. Claude's stated position: no calls to IOA members who don't know it is an AI unless the opening says it is sir's AI voice ("meri AI awaaz mein"). The KB v1 from sir also says calls must open as an AI. The owner says a 20-member human team is calling; Sunny is part of it.
- Never send keys in chat. Ads/spend need owner approval.

## Open items
1. Install APK v2 on the Flip (fixes the silent first ~2.5 s).
2. Check whether the 85116 24442 caller heard the greeting (4 s silence on that call).
3. Gujarati wording for Gujarat members (needs sir's 3 lines in Gujarati; members.csv has a state column).
4. Re-clone the voice from a 2–3 min phone recording of sir talking normally (or PVC from 30–60 min).
5. Member name sheet (`~/stacks/ioa-broadcast/members.csv`, 8,748 rows).
6. Live takeover by sir mid-call (not built).
7. Stop the `openline` and `el-bridge` containers when not testing. Rotate keys that were pasted in chat (ElevenLabs, Twilio, Exotel, Sarvam, OpenLine setup).
