Skip to content

Commit 78d705f

Browse files
authored
feat: Add Blocks documentation and examples (VapiAI#125)
1 parent 9579754 commit 78d705f

File tree

6 files changed

+158
-1
lines changed

6 files changed

+158
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77
### Development
88

99
`mintlify dev`
10+
11+
12+
### Errors
13+
14+
If you encounter an issue try setting "openapi" value from "https://api.vapi.ai/api-json" to "./api.json" in mint.json

blocks.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: "Introduction"
3+
sidebarTitle: "Introduction"
4+
description: "Breaking down bot conversations into smaller, more manageable prompts"
5+
---
6+
7+
8+
We're currently running a beta for **Blocks**, an upcoming feature from [Vapi.ai](http://vapi.ai/) aimed at improving bot conversations. The problem we've noticed is that single LLM prompts are prone to hallucinations, unreliable tool calls, and can’t handle many-step complex instructions.
9+
10+
**By breaking the conversation into smaller, more manageable prompts**, we can guarantee the bot will do this, then that, or if this happens, then that happens. It’s like having a checklist for conversations — less room for error, more room for getting things right.
11+
12+
13+
Here’s an example: For food ordering, this is what a prompt would look like.
14+
15+
16+
<Accordion title="Without Blocks">
17+
Example Prompt
18+
19+
```jsx
20+
[Identity]
21+
You are a friendly and efficient assistant for a food truck that serves burgers, fries, and drinks.
22+
23+
[Task]
24+
1. Greet the customer warmly and inquire about their main order.
25+
2. Offer suggestions for the main order if needed.
26+
3. If they choose a burger, suggest upgrading to a combo with fries and a drink, offering clear options (e.g., regular or special fries, different drink choices).
27+
4. Confirm the entire order to ensure accuracy.
28+
5. Suggest any additional items like desserts or sauces.
29+
6. Thank the customer and let them know when their order will be ready.
30+
```
31+
32+
</Accordion>
33+
34+
<Accordion title="With Blocks">
35+
<Frame>
36+
<img src="/static/images/blocks/food-order-steps.png" />
37+
</Frame>
38+
</Accordion>
39+
40+
41+
42+
There are three core types of Blocks: [Conversation](https://api.vapi.ai/api#:~:text=ConversationBlock), [Tool-call](https://api.vapi.ai/api#:~:text=ToolCallBlock), and [Workflow](https://api.vapi.ai/api#:~:text=WorkflowBlock). Each type serves a different role in shaping how your assistant engages with users.
43+
44+
45+
<Note>
46+
Blocks is currently in beta. We're excited to have you try this new feature and welcome your [feedback](https://discord.com/invite/pUFNcf2WmH) as we continue to refine and improve the experience.
47+
</Note>
48+
49+
## Advanced Concepts
50+
51+
<CardGroup cols={2}>
52+
<Card title="Steps" icon="stairs" href="/blocks/steps">
53+
Learn how to structure the flow of your conversation
54+
</Card>
55+
<Card title="Block Types" icon="boxes-stacked" href="/blocks/block-types">
56+
Explore the different block types and how to use them
57+
</Card>
58+
</CardGroup>

blocks/block-types.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Block Types"
3+
sidebarTitle: "Block Types"
4+
description: "Building the Logic and Actions for Each Step in Your Conversation "
5+
---
6+
7+
[**Blocks**](https://api.vapi.ai/api#/Blocks/BlockController_create) are the functional units within a Step, defining what action happens at each stage of a conversation. Each Step can contain only one Block, and there are three main types of Blocks, each designed to handle different aspects of conversation flow.
8+
9+
<Note>
10+
Blocks is currently in beta. We're excited to have you try this new feature and welcome your [feedback](https://discord.com/invite/pUFNcf2WmH) as we continue to refine and improve the experience.
11+
</Note>
12+
13+
#### Types
14+
15+
- [**Conversation:**]((https://api.vapi.ai/api#:~:text=ConversationBlock)) This block type manages interactions between the assistant and the user. A conversation block is used when the assistant needs to ask the user for specific information, such as contact details or preferences.
16+
- [**Tool-call:**](https://api.vapi.ai/api#:~:text=ToolCallBlock) This block allows the assistant to make external tool calls.
17+
- [**Workflow:**](https://api.vapi.ai/api#:~:text=WorkflowBlock) This block type enables the creation of subflows, which are smaller sets of steps executed within a Block. It can contain an array of steps (`steps[]`) and uses an `inputSchema` to define the data needed to initiate the workflow, along with an `outputSchema` to handle the data returned after completing the subflow. Workflow blocks are ideal for organizing complex processes or reusing workflows across different parts of the conversation.

blocks/steps.mdx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: "Steps"
3+
sidebarTitle: "Steps"
4+
description: "Building and Controlling Conversation Flow for Your Assistants"
5+
---
6+
7+
[**Steps**](https://api.vapi.ai/api#:~:text=HandoffStep) are the core building blocks that dictate how conversations progress in a bot interaction. Each Step represents a distinct point in the conversation where the bot performs an action, gathers information, or decides where to go next. Think of Steps as checkpoints in a conversation that guide the flow, manage user inputs, and determine outcomes.
8+
9+
<Note>
10+
Blocks is currently in beta. We're excited to have you try this new feature and welcome your [feedback](https://discord.com/invite/pUFNcf2WmH) as we continue to refine and improve the experience.
11+
</Note>
12+
13+
#### Features
14+
15+
- **Output:** The data or response expected from the step, as outlined in the block's `outputSchema`.
16+
- **Input:** The data necessary for the step to execute, defined in the block's `inputSchema`.
17+
- [**Destinations:**](https://api.vapi.ai/api#:~:text=StepDestination) This can be determined by a simple linear progression or based on specific criteria, like conditions or rules set within the Step. This enables dynamic decision-making, allowing the assistant to choose the next Step depending on what happens during the conversation (e.g., user input, a specific value, or a condition being met).
18+
19+
#### Example
20+
21+
```json
22+
{
23+
"type": "handoff",
24+
"name": "get_user_order",
25+
"input": {
26+
"name": "John Doe",
27+
"email": "johndoe@example.com"
28+
},
29+
"destinations": [
30+
{
31+
"type": "step",
32+
"stepName": "confirm_order",
33+
"conditions": [
34+
{
35+
"type": "model-based",
36+
"instruction": "If the user has provided an order"
37+
}
38+
]
39+
}
40+
],
41+
"block": {
42+
"name": "ask_for_order",
43+
"type": "conversation",
44+
"inputSchema": {
45+
"type": "object",
46+
"required": ["name", "email"],
47+
"properties": {
48+
"name": { "type": "string", "description": "The customer's name" },
49+
"email": { "type": "string", "description": "The customer's email" }
50+
}
51+
},
52+
"instruction": "Greet the customer and ask for their name and email. Then ask them what they'd like to order.",
53+
"outputSchema": {
54+
"type": "object",
55+
"required": ["orders", "name"],
56+
"properties": {
57+
"orders": {
58+
"type": "string",
59+
"description": "The customer's order, e.g., 'burger with fries'"
60+
},
61+
"name": {
62+
"type": "string",
63+
"description": "The customer's name"
64+
}
65+
}
66+
}
67+
}
68+
}
69+
```

mint.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@
178178
"assistants/background-messages"
179179
]
180180
},
181+
{
182+
"group": "Blocks",
183+
"pages": [
184+
"blocks",
185+
"blocks/steps",
186+
"blocks/block-types"
187+
]
188+
},
181189
{
182190
"group": "Server URL",
183191
"pages": [
@@ -540,5 +548,5 @@
540548
"measurementId": "G-G6EN8MLZLK"
541549
}
542550
},
543-
"openapi": "https://api.vapi.ai/api-json"
551+
"openapi": "./api.json"
544552
}
58.6 KB
Loading

0 commit comments

Comments
 (0)