For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.telcoflow.com/use-cases/llms.txt. For full documentation content, see https://docs.telcoflow.com/use-cases/llms-full.txt.

# Real-time Call Monitoring and Coaching

A supervisor silently monitors a live call between a customer and a human agent, with the ability to whisper coaching instructions that only the agent hears.

## Overview

This use case demonstrates:
- 3-way conference with `connect()`
- Silent monitoring with `spy()`
- Private coaching with `whisper()`
- Real-time AI-powered conversation analysis
- Live sentiment and topic logging

**State flow:** PENDING -> ANSWERED -> CONNECTED (optionally followed by `close()` if the AI later leaves the conference)

## Example

```python
@client.on(events.INCOMING_CALL)
async def monitored_call(call: ActiveCall):
    """Connect caller to an agent with supervisor monitoring."""
    await call.answer()

    # Brief AI greeting before connecting
    await call.send_audio(
        await tts.synthesize("Please hold while I connect you to an agent.")
    )

    # Connect to the original callee (creates a 3-way conference)
    await call.connect()

    # Start in spy mode to silently monitor
    await call.spy()

    # AI analyzes the conversation in real-time
    async for chunk in call.audio_stream():
        analysis = await ai_model.analyze_conversation(chunk)

        if analysis.coaching_suggestion:
            # Switch to whisper mode to coach the agent privately
            await call.whisper()
            await call.send_audio(
                await tts.synthesize(analysis.coaching_suggestion)
            )
            # Switch back to spy mode
            await call.spy()

        # Log call analytics
        await db.log_call_analytics(
            call_id=call.call_id,
            sentiment=analysis.sentiment,
            topics=analysis.topics,
        )
```

## How It Works

1. The AI answers the call with a brief greeting
2. The call is connected to the original callee using `connect()`, creating a 3-way conference
3. The AI switches to `spy()` mode, silently listening to both sides
4. In real-time, the AI analyzes the conversation for sentiment, topics, and coaching opportunities
5. When the AI has a coaching suggestion (e.g., "The customer seems frustrated, try offering a discount"), it:
   - Switches to `whisper()` mode
   - Speaks the coaching suggestion (only the human agent hears it, not the caller)
   - Switches back to `spy()` mode
6. Throughout the call, analytics (sentiment scores, topics discussed) are logged to a database

## Conference Audio Modes

| Mode | Caller Hears Agent? | Callee Hears Agent? | Agent Hears Both? |
|---|---|---|---|
| `barge()` | Yes | Yes | Yes |
| `whisper()` | No | Yes | Yes |
| `spy()` | No | No | Yes |

## Key Commands Used

- [`answer()`](/concepts/call-commands#answer) - Answer the incoming call
- [`connect()`](/concepts/call-commands#connectring_time_seconds60) - Create the 3-way conference
- [`spy()`](/concepts/call-commands#spy) - Silent monitoring
- [`whisper()`](/concepts/call-commands#whisper) - Private coaching audio
- [`send_audio()`](/concepts/audio-streaming#sending-audio) - Deliver coaching to the agent

## Related

- [AI Agent with Human Escalation](/use-cases/human-escalation) - AI-to-human handoff pattern
- [Call States](/concepts/call-states-and-lifecycle) - Understanding the CONNECTED state