Skip to content

Commit 936df11

Browse files
committed
docs(squads): add ts/python/curl tabs to ecommerce example
1 parent 75583d1 commit 936df11

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

fern/squads/examples/ecommerce-order-management.mdx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,65 @@ Use Squads to split responsibilities: an Orders assistant handles tracking/statu
3535
- Any → VIP for high‑value customers or sentiment issues
3636
- Warm-transfer summary for human agents if needed
3737

38-
## 3. Test and validate
38+
## 3. Implement
39+
40+
<Tabs>
41+
<Tab title="TypeScript (Server SDK)">
42+
```typescript
43+
import { VapiClient } from "@vapi-ai/server-sdk";
44+
const vapi = new VapiClient({ token: process.env.VAPI_API_KEY! });
45+
46+
await vapi.calls.create({
47+
transport: { type: "web" },
48+
squad: {
49+
members: [
50+
{ assistant: { name: "Orders", model: { provider: "openai", model: "gpt-4o", messages: [{ role: "system", content: "Orders specialist. Handle tracking and delivery questions." }] }, firstMessage: "Hello, how can I help with your order?", firstMessageMode: "assistant-speaks-first" } },
51+
{ assistant: { name: "Returns", model: { provider: "openai", model: "gpt-4o", messages: [{ role: "system", content: "Returns specialist. Check eligibility and generate labels." }] } } },
52+
{ assistant: { name: "VIP", model: { provider: "openai", model: "gpt-4o", messages: [{ role: "system", content: "VIP concierge. Prioritize premium customers and coordinate resolutions." }] } } }
53+
],
54+
},
55+
});
56+
```
57+
</Tab>
58+
59+
<Tab title="Python (Server SDK)">
60+
```python
61+
import os
62+
from vapi import Vapi
63+
64+
client = Vapi(token=os.getenv("VAPI_API_KEY"))
65+
client.calls.create(
66+
transport={"type": "web"},
67+
squad={
68+
"members": [
69+
{"assistant": {"name": "Orders", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "Orders specialist. Handle tracking and delivery questions."}]}, "first_message": "Hello, how can I help with your order?", "first_message_mode": "assistant-speaks-first"}},
70+
{"assistant": {"name": "Returns", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "Returns specialist. Check eligibility and generate labels."}]}}},
71+
{"assistant": {"name": "VIP", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "VIP concierge. Prioritize premium customers and coordinate resolutions."}]}}},
72+
]
73+
},
74+
)
75+
```
76+
</Tab>
77+
78+
<Tab title="cURL (web)">
79+
```bash
80+
curl -X POST "https://api.vapi.ai/call/web" \
81+
-H "Authorization: Bearer $VAPI_API_KEY" \
82+
-H "Content-Type: application/json" \
83+
-d '{
84+
"squad": {
85+
"members": [
86+
{ "assistant": { "name": "Orders", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "Orders specialist. Handle tracking and delivery questions."}] }, "firstMessage": "Hello, how can I help with your order?", "firstMessageMode": "assistant-speaks-first" } },
87+
{ "assistant": { "name": "Returns", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "Returns specialist. Check eligibility and generate labels."}] } } },
88+
{ "assistant": { "name": "VIP", "model": {"provider": "openai", "model": "gpt-4o", "messages": [{"role": "system", "content": "VIP concierge. Prioritize premium customers and coordinate resolutions."}] } } }
89+
]
90+
}
91+
}'
92+
```
93+
</Tab>
94+
</Tabs>
95+
96+
## 4. Test and validate
3997

4098
Attach a phone number to the Squad and simulate order, return, and VIP scenarios.
4199

0 commit comments

Comments
 (0)