Skip to content

Commit 756065a

Browse files
committed
Add docs for flush syntax, idle messages, and customer join timeout + update navigation
1 parent e48a9e2 commit 756065a

File tree

4 files changed

+879
-0
lines changed

4 files changed

+879
-0
lines changed

fern/assistants/flush-syntax.mdx

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
title: Flush syntax
3+
subtitle: Control voice transmission timing for responsive conversations
4+
slug: assistants/flush-syntax
5+
description: Force immediate voice transmission with VAPI's flush syntax for real-time interactions
6+
---
7+
8+
## Overview
9+
10+
The flush syntax is a VAPI audio control token that forces immediate transmission of LLM output to voice providers, eliminating buffering delays for real-time voice interactions.
11+
12+
**When to use flush syntax:**
13+
14+
- Acknowledge user requests immediately during processing
15+
- Provide feedback during long-running tool executions
16+
- Create natural conversation pauses
17+
- Support custom LLM integrations with processing delays
18+
19+
<Tip>
20+
Use flush strategically—overuse can cause audio fragmentation and degrade
21+
conversation quality.
22+
</Tip>
23+
24+
## How it works
25+
26+
The flush syntax bypasses normal buffering to provide immediate audio feedback:
27+
28+
1. **Detection**: VAPI scans LLM output for flush syntax using regex pattern
29+
2. **Split**: Text is divided at the flush position
30+
3. **Immediate Send**: Content before flush is sent instantly to voice provider
31+
4. **Continue**: Remaining text follows normal buffering
32+
33+
<CodeBlocks>
34+
```typescript title="Processing Example"
35+
const { sendToTTS, flush, remainingBuffer } = ttsBuffer(buffer, voice);
36+
if (sendToTTS.length > 0) {
37+
pushBuffer(sendToTTS, flush); // flush=true triggers immediate send
38+
buffer = remainingBuffer;
39+
}
40+
```
41+
```python title="Conceptual Flow"
42+
# 1. LLM generates: "I'm processing your request... <flush /> Here's the result"
43+
# 2. VAPI detects flush syntax
44+
# 3. Sends "I'm processing your request..." immediately to voice
45+
# 4. Continues with "Here's the result" using normal buffering
46+
```
47+
</CodeBlocks>
48+
49+
## Syntax formats
50+
51+
VAPI supports three flush formats with case-insensitive matching:
52+
53+
<CodeBlocks>
54+
```html title="Self-closing (Recommended)"
55+
<flush />
56+
``` ```html title="Opening tag"
57+
<flush>``` ```html title="Closing tag"</flush>
58+
```
59+
</CodeBlocks>
60+
61+
<Note>
62+
All formats use regex pattern `/<\s*flush\s*\/?>|<\s*\/\s*flush\s*>/i` allowing whitespace variations.
63+
</Note>
64+
65+
## Configuration requirements
66+
67+
Flush syntax requires proper voice configuration:
68+
69+
<CodeBlocks>
70+
```json title="Assistant Configuration"
71+
{
72+
"voice": {
73+
"chunkPlan": {
74+
"enabled": true // Required for flush to work
75+
}
76+
}
77+
}
78+
```
79+
```typescript title="TypeScript SDK"
80+
const assistant = await vapi.assistants.create({
81+
voice: {
82+
chunkPlan: {
83+
enabled: true
84+
}
85+
}
86+
// ... other configuration
87+
});
88+
```
89+
</CodeBlocks>
90+
91+
<Warning>
92+
Flush will NOT work when `chunkPlan.enabled: false`. The tags will appear in
93+
voice output instead of being processed.
94+
</Warning>
95+
96+
## Usage examples
97+
98+
### Basic acknowledgment
99+
100+
```javascript
101+
"I'm processing your request... <flush /> Let me check that for you.";
102+
```
103+
104+
### Tool processing feedback
105+
106+
```javascript
107+
"Looking up that information... <flush /> This may take a moment.";
108+
```
109+
110+
### Conversation flow
111+
112+
```javascript
113+
"That's a great question. <flush /> Based on the data I have...";
114+
```
115+
116+
### Custom LLM integration
117+
118+
```javascript
119+
"Here's your answer: 42. <flush /> Would you like an explanation?";
120+
```
121+
122+
## Best practices
123+
124+
### When to use flush
125+
126+
<CardGroup cols={2}>
127+
<Card title="Acknowledge requests" icon="check">
128+
Immediately confirm you've received and understood the user's request
129+
</Card>
130+
<Card title="Long operations" icon="clock">
131+
Provide feedback during tool calls or processing that takes time
132+
</Card>
133+
<Card title="Natural pauses" icon="pause">
134+
Create conversation breaks at logical points
135+
</Card>
136+
<Card title="Custom delays" icon="gear">
137+
Support external LLM integrations with processing delays
138+
</Card>
139+
</CardGroup>
140+
141+
### When to avoid flush
142+
143+
- **Every response** - Causes audio fragmentation
144+
- **Mid-sentence** - Breaks natural speech flow
145+
- **Short responses** - Normal buffering is sufficient
146+
- **Multiple per response** - Can create choppy audio
147+
148+
### Implementation guidelines
149+
150+
1. **Place at natural boundaries** - Use between complete thoughts or sentences
151+
2. **Test with your voice provider** - Effectiveness varies by provider
152+
3. **Monitor conversation quality** - Ensure audio remains smooth and natural
153+
4. **Document usage** - Include in code comments for team understanding
154+
155+
## Advanced usage
156+
157+
### Dynamic insertion
158+
159+
```typescript
160+
const acknowledgment = "I understand your request";
161+
const detailedResponse = await processRequest(userInput);
162+
const responseWithFlush = `${acknowledgment} <flush /> ${detailedResponse}`;
163+
```
164+
165+
### System prompt integration
166+
167+
```javascript
168+
const systemPrompt = `When providing lengthy responses, use <flush /> after acknowledging the user's request to provide immediate feedback.`;
169+
```
170+
171+
### Nested handling
172+
173+
```javascript
174+
"Starting process... <flush> Step 1 complete </flush> Moving to step 2...";
175+
```
176+
177+
## Troubleshooting
178+
179+
<AccordionGroup>
180+
<Accordion title="Flush tags appear in voice output">
181+
**Cause**: `chunkPlan.enabled` is set to `false` or missing **Solution**: -
182+
Verify `chunkPlan.enabled: true` in voice configuration - Check assistant
183+
configuration in dashboard or API calls - Test with a minimal configuration
184+
to isolate the issue
185+
</Accordion>
186+
187+
{" "}
188+
<Accordion title="Syntax not recognized">
189+
**Cause**: Malformed flush syntax or typos **Solution**: - Use exact formats:
190+
`<flush />
191+
`, `<flush>`, or `</flush>` - Avoid extra parameters or attributes - Check for
192+
typos in tag spelling
193+
</Accordion>
194+
195+
<Accordion title="Audio sounds choppy or fragmented">
196+
**Cause**: Overuse of flush syntax
197+
**Solution**:
198+
- Reduce flush frequency in responses
199+
- Place only at sentence boundaries
200+
- Test with real users to
201+
validate experience
202+
</Accordion>
203+
</AccordionGroup>
204+
205+
## Technical considerations
206+
207+
### Provider compatibility
208+
209+
- **Effectiveness varies** by voice provider
210+
- **Test thoroughly** with your chosen provider
211+
- **Monitor performance** impact on response times
212+
213+
### Cost implications
214+
215+
- **Increased API calls** to voice provider
216+
- **Higher usage** on usage-based pricing
217+
- **Monitor billing** if using flush frequently
218+
219+
### VAPI-only feature
220+
221+
- **Platform exclusive** - not available on other voice platforms
222+
- **Configuration dependent** - requires chunking enabled
223+
- **Version specific** - ensure using compatible VAPI version
224+
225+
## Next steps
226+
227+
Now that you understand flush syntax:
228+
229+
- **[Voice formatting plan](/assistants/voice-formatting-plan):** Control voice output formatting and timing
230+
- **[Background messages](/assistants/background-messages):** Send messages during conversations
231+
- **[Custom tools](/tools/custom-tools):** Build tools that benefit from flush syntax feedback

0 commit comments

Comments
 (0)