You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/tools/handoff.mdx
+67-7Lines changed: 67 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -321,7 +321,11 @@ Control what conversation history is passed to the next assistant:
321
321
322
322
## Variable Extraction
323
323
324
-
Extract and pass structured data during handoff:
324
+
Extract and pass structured data during handoff. Variables extracted by the handoff tool are available to all subsequent assistants in the conversation chain.
325
+
When a handoff extracts a variable with the same name as an existing one, the new value replaces the previous value.
326
+
327
+
### 1. `variableExtractionPlan` in destinations
328
+
This extraction method will make an OpenAI structured output request to extract variables. Use this method if you have multiple destinations, each with different variables that need to be extracted.
325
329
326
330
```json
327
331
{
@@ -331,12 +335,8 @@ Extract and pass structured data during handoff:
331
335
"destinations": [
332
336
{
333
337
"type": "assistant",
334
-
"assistantId": "order-processing-assistant",
338
+
"assistantName": "order-processing-assistant",
335
339
"description": "customer is ready to place an order",
336
-
"contextEngineeringPlan": {
337
-
"type": "lastNMessages",
338
-
"maxMessages": 5
339
-
},
340
340
"variableExtractionPlan": {
341
341
"schema": {
342
342
"type": "object",
@@ -377,6 +377,66 @@ Extract and pass structured data during handoff:
377
377
}
378
378
```
379
379
380
+
### 2. `tool.function`
381
+
We will also extract variables in the tool call parameters from the LLM tool call (in addition to sending these parameters to your server in a `handoff-destination-request` in a dynamic handoff). Be sure to include the `destination` parameter with the assistant names or IDs in `enum`, as that is how Vapi determines where to handoff the call to. The `destination` parameter will not be extracted as a variable. Also, remember to add `destination` and all other variables that are required to the JsonSchema's `required` array.
382
+
383
+
```json
384
+
{
385
+
"tools": [
386
+
{
387
+
"type": "handoff",
388
+
"destinations": [
389
+
{
390
+
"type": "assistant",
391
+
"assistantName": "order-processing-assistant",
392
+
"description": "customer is ready to place an order",
393
+
}
394
+
],
395
+
"function": {
396
+
"name": "handoff_to_order_processing_assistant",
397
+
"parameters": {
398
+
"type": "object",
399
+
"properties": {
400
+
"description": {
401
+
"type": "string",
402
+
"description": "The destination to handoff the call to.",
403
+
"enum": ["order-processing-assistant"]
404
+
},
405
+
"customerName": {
406
+
"type": "string",
407
+
"description": "Full name of the customer"
408
+
},
409
+
"email": {
410
+
"type": "string",
411
+
"format": "email",
412
+
"description": "Customer's email address"
413
+
},
414
+
"productIds": {
415
+
"type": "array",
416
+
"items": {
417
+
"type": "string"
418
+
},
419
+
"description": "List of product IDs customer wants to order"
Override the default function definition for more control. You can overwrite the function name for each tool to put into the system prompt or pass custom parameters in a dynamic handoff request.
@@ -387,7 +447,7 @@ Override the default function definition for more control. You can overwrite the
387
447
{
388
448
"type": "handoff",
389
449
"function": {
390
-
"name": "transfer_to_department",
450
+
"name": "handoff_to_department",
391
451
"description": "Transfer the customer to the appropriate department based on their needs. Only use when explicitly requested or when the current assistant cannot help.",
0 commit comments