Skip to content

Commit bc2636c

Browse files
authored
Add docs for variables and overrides on assistants (#68)
- Add docs to add template variables and how to override them
1 parent 65cc526 commit bc2636c

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

assistants/persistent-assistants.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,34 @@ The `/assistant` endpoint is there for convenience to save you creating your own
1414
</Accordion>
1515

1616
Otherwise, you can just specify the assistant configuration when starting a call.
17+
18+
## Variables
19+
20+
Prompts, messages, and other assistant properties can be dynamically set when starting a call based on templates.
21+
These templates are defined using double curly braces `{{variableName}}`.
22+
This is useful when you want to customize the assistant for a specific call.
23+
24+
For example, you could set the assistant's first message to "Hello, `{{name}}`!" and then set `name` to `John` when starting the call
25+
by passing `assistantOverrides` with `variableValues` to the API or SDK:
26+
27+
```json
28+
{
29+
"variableValues": {
30+
"name": "John"
31+
}
32+
}
33+
```
34+
35+
#### Default variables
36+
37+
By default, the following variables are automatically filled based on the current (UTC) time,
38+
meaning that you don't need to set them manually in `variableValues`:
39+
40+
| Variable | Description | Example |
41+
| ----------- | ------------------------------ | -------------------- |
42+
| `{{now}}` | Current date and time (UTC) | Jan 1, 2024 12:00 PM |
43+
| `{{date}}` | Current date (UTC) | Jan 1, 2024 |
44+
| `{{time}}` | Current time (UTC) | 12:00 PM |
45+
| `{{month}}` | Current month (UTC) | January |
46+
| `{{day}}` | Current day of month (UTC) | 1 |
47+
| `{{year}}` | Current year (UTC) | 2024 |

quickstart/web.mdx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ vapi.start(assistantOptions);
130130

131131
More configuration options can be found in the [Assistant](/api-reference/assistants/create-assistant) API reference.
132132

133-
### Option 2: Persistant Assistant
133+
### Option 2: Persistent Assistant
134134

135135
If you want to create an assistant that you can reuse across multiple calls, you can create a persistent assistant in the [Vapi Dashboard](https://dashboard.vapi.ai). Here's how you can do that:
136136

@@ -144,8 +144,28 @@ Then, you can copy the assistant's ID at the top of the assistant detail page:
144144
<img src="/static/images/quickstart/assistant-id-dashboard.png" />
145145
</Frame>
146146

147-
Now we can call `.start()`, passing the persistant assistant's ID:
147+
Now we can call `.start()`, passing the persistent assistant's ID:
148148

149149
```javascript
150150
vapi.start("79f3XXXX-XXXX-XXXX-XXXX-XXXXXXXXce48");
151151
```
152+
153+
If you need to override any assistant settings or set template variables, you can pass `assistantOverrides` as the second argument.
154+
155+
For example, if the first message is "Hello `{{name}}`", you can set `assistantOverrides` to replace `{{name}}` with `John`:
156+
157+
```javascript
158+
const assistantOverrides = {
159+
transcriber: {
160+
provider: "deepgram",
161+
model: "nova-2",
162+
language: "en-US",
163+
},
164+
recordingEnabled: false,
165+
variableValues: {
166+
name: "John",
167+
},
168+
};
169+
170+
vapi.start("79f3XXXX-XXXX-XXXX-XXXX-XXXXXXXXce48", assistantOverrides);
171+
```

sdk/web.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ vapi.start({
7070
});
7171
```
7272

73+
#### Overriding Assistant Configurations
74+
75+
To override assistant settings or set template variables, you can pass `assistantOverrides` as the second argument.
76+
77+
For example, if the first message is "Hello `{{name}}`", set `assistantOverrides` to the following to replace `{{name}}` with `John`:
78+
79+
```javascript
80+
const assistantOverrides = {
81+
transcriber: {
82+
provider: "deepgram",
83+
model: "nova-2",
84+
language: "en-US",
85+
},
86+
recordingEnabled: false,
87+
variableValues: {
88+
name: "Alice",
89+
},
90+
};
91+
92+
vapi.start("79f3XXXX-XXXX-XXXX-XXXX-XXXXXXXXce48", assistantOverrides);
93+
```
94+
7395
### `.send()`
7496

7597
During the call, you can send intermediate messages to the assistant (like [background messages](/assistants/background-messages)).

0 commit comments

Comments
 (0)