Sep 6, 2026

Wait, Actually… — Adaptive AI Sales & Negotiation Agent

artificial-intelligence ai-agent voice-ai sales react

 

 Purpose & Goals

 

Purpose:Convert live inbound interest into qualified demos/meetings through an always-available, voice-native sales agent that feels like talking to a human associate — and never breaks when a customer interrupts, changes requirements, or raises an objection.

 

Goals:
1. Qualify by voice — extract users, budget, and use-case from spoken input.
2.Handle objections dynamically— pricing, trust/security, and product questions, each adapted to what was already said.
3. Remember everything— a live memory layer tracks every changed detail and re-acknowledges updates ("You said 10, I'll update to 25").
4. Negotiate in real time— multi-round concession offers (15% → 25% → 30%) with accept/counter.
5. Reach a clear outcome — book a demo + create a CRM lead, or escalate to a human with full context

 

## Tech Stack

 

| Layer | Tech |
|---|---|
| Voice transport | **Agora RTC** (Web SDK `agora-rtc-sdk-ng`, `agora-rtm`) |
| Agent orchestration | **Agora Conversational AI Engine** (STT + LLM + TTS) |
| Speech-to-text | **Deepgram `nova-3`** (via Agora managed ASR) |
| Reasoning (voice) | **OpenAI `gpt-4o-mini`** (managed LLM) + Emily Carter system prompt |
| Text-to-speech | **Minimax `speech-2.6-turbo`** (managed TTS) |
| Turn-taking / interruption | **Agora Voice-Activity Detection** (agent yields on VAD) |
| Backend | Node.js + Express |
| Frontend | Vite + React |
| Mock fallback (dev) | Browser `SpeechRecognition` + `speechSynthesis` |
| Optional LLM (mock) | `OPENAI_API_KEY` → natural, non-scripted replies |

 

 

 

Architecture

 

```
            ┌─────────────────────────────────────────────────────────┐
            │                    Browser (Vite / React)              │
            │  VoiceConsole ◄──► agoraService.js (RTC + Voice AI)     │
            │        ▲                          ▲                    │
            │        │ mic / TTS (mock)         │ real voice path    │
            │        ▼                          ▼                    │
            │  ┌──────────┐  /api  ┌──────────────────────────┐       │
            │  │   App    │────────│         BACKEND          │       │
            │  │(state + │        │  server.js (Express :4000) │       │
            │  │ UI)     │        │  engine.js  ◄ products.js │       │
            │  └──────────┘        │  calendar.js  CRM lead   │       │
            │                      │  agoraClient.js (join)    │       │
            │                      └──────┬─────────────────────┘       │
            └─────────────────────────────┼────────────────────────────┘
                                          │ managed by Agora
                                          ▼
                              STT(Deepgram) → LLM(OpenAI) → TTS(Minimax)
                              VAD → interruption handling → live memory
```

 

 Voice path (production)
`frontend/src/agoraService.js` → `POST /api/agora/join` → `backend/agoraClient.js:startAgent()` creates an Agora Conversational AI agent on the channel. Agora's engine runs Deepgram STT → OpenAI LLM (with the **Emily Carter** system prompt) → Minimax TTS, with VAD driving natural turn-taking and interruption. The transcript is streamed back to the UI via the `agora-agent-client-toolkit`.
 
 Mock path (dev, no Agora creds)
When Agora credentials are absent/placeholder, `isConfigured()` returns false and the app runs the **adaptive rule engine**:
`browser SpeechRecognition` → `POST /api/message` → `engine.processMessage()` → `speechSynthesis`. This path is fully functional and demonstrates all the same capabilities.

 

Project Layout
 
backend/
  server.js        # Express routes: session, message, crm, products, knowledge, calendar, escalate
  engine.js        # Adaptive sales agent: state machine, memory, objections, negotiation (Emily)
  products.js      # Knowledge base: plans, features, FAQ, competitors + retrieval
  calendar.js      # Mock calendar: availability slots + booking
  agoraClient.js   # Agora agent join/leave + Emily Carter system prompt
frontend/
  src/
    App.jsx             # Orchestration, state, demo-stage jumping
    api.js              # API client (session, message, crm, products, calendar, escalate)
    agoraService.js     # RTC/Voice-AI client + mock STT/TTS + transcript listeners
    components/
      VoiceConsole.jsx  # Mic/orb/waveform, auto-listen, slot chips, negotiate, escalate
      Transcript.jsx    # Live transcript with partial + typing indicator
      MemoryPanel.jsx   # Live memory layer (users trail, budget, competitor, objections)
      NegotiationRadar.jsx  # Fit radar + recommended plan
      JourneyTimeline.jsx   # Qualifying → Negotiating → Demo → Booked
      CrmPanel.jsx      # Lead / escalation ticket card
      Header.jsx        # Stage track (qualifying…booked, escalated, closed)
 

 

**For the real voice path:** add real credentials to `backend/.env`:
`AGORA_APP_ID`, `AGORA_APP_CERTIFICATE`, `AGORA_CUSTOMER_ID`, `AGORA_CUSTOMER_SECRET`, and optionally `OPENAI_API_KEY` for non-scripted reasoning. Mock mode activates automatically when credentials are placeholders/absent.

 

 

## Conversation Journey (5 stages)

 

1. **Qualifying** — "How many users are we planning for?" / "What's your budget?"
2. **Presenting** — plan recommendation + value pitch (retrieved from KB).
3. **Negotiating** — objection handling → real-time concession offers.
4. **Ready to Book** — demo request → availability slots offered.
5. **Booked / Escalated** — demo confirmed (CRM lead created) or human handoff (ticket w/ full context).

 

---

 

## Example Scenario (the one from the problem statement)

 

| Customer | Agent state change |
|---|---|
| "I'm looking at pricing for our team." | → Qualifying: asks for user count |
| "We have 10 users, budget ₹20,000, that feels expensive, compare with HubSpot" | → Memory updated; competitor compare + pricing objection handled **in one turn** |
| "Actually, make it 25 users" | → Memory updated 10→25; Growth plan re-recommended |
| "That's too expensive — can you do better?" | → Negotiation round 1: 15% off annual |
| "Still too high" | → Negotiation round 2: 25% off + bonus features |
| "Deal, that works for me" | → Deal locked |
| "Can I book an enterprise demo at 4pm tomorrow?" | → Slot booked; CRM lead created (users=25, competitor=HubSpot, budget=20000, booking_id) 

 

---
 Key Capabilities at a Glance

 

- **Natural turn-taking + interruption** — Agora VAD yields the agent mid-response; mock path cancels TTS on mic press + auto-re-listens after each reply.
- **Adapts mid-call** — requirements, user count, and budget can change and the agent re-derives the right plan/reply on the fly.
- **No fixed script** — replies are assembled from live memory + retrieved KB facts; voice path delegates wording to the LLM (Emily).
- **Live memory layer** — `usersHistory`, `budgetHistory`, objections, competitor, use-case, full transcript, decision log.
- **Objection handling** — pricing (value pitch + guarantee + step-down), trust (SOC-2/GDPR/SLA/30-day guarantee), product (FAQ/feature retrieval).
- **Real negotiation** — 3-round concession ladder with accept/counter/redirect-to-demo.
- **CRM + calendar + escalation** — `/api/crm`, `/api/calendar/book`, `/api/escalate` (carries the full session transcript as context).
- **Clear outcomes** — `session.outcome` = `booked` | `escalated` | `closed`.

This build was uploaded as a hackathon project

Hackathon

EchoSphere

View All Projects
Give a star to encourage!Discussion
Start a new conversation!
Login to join the discussion

More Builds by Somi Shah

buildwithagora voiceai conversational-ai webrtc jansetu