Skip to content

Commit 8fa11b8

Browse files
committed
docs: refresh repo usage and add webhook testing scaffolding
Update project docs and agent guidance for multi-environment GitOps usage, add a local mock webhook server workflow, and document changelog discipline for significant resource changes.
1 parent 4568ec3 commit 8fa11b8

10 files changed

Lines changed: 1264 additions & 14 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
description: Require changelog updates for significant config changes
3+
alwaysApply: true
4+
---
5+
6+
# Changelog Update Requirement
7+
8+
When making significant configuration changes, update `docs/changelog.md` in the same change.
9+
10+
Significant changes include:
11+
- Assistant changes (prompt/body/frontmatter updates)
12+
- Tool changes (new tools, parameter/behavior changes)
13+
- Squad changes (members, handoffs, overrides, routing)
14+
- Structured output or simulation changes that affect behavior
15+
16+
Changelog entries should include:
17+
- Date section (`YYYY-MM-DD`)
18+
- Resource type and file path(s)
19+
- What changed, why it changed, and expected impact

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Vapi GitOps — copy values into environment-specific files (never commit real keys).
2+
#
3+
# This repo loads secrets from `.env.<environment>` when you run commands, e.g.:
4+
# - `.env.dev` → `npm run push:dev`, `npm run pull:dev`, etc.
5+
# - `.env.stg` → `npm run push:stg`, …
6+
# - `.env.prod` → `npm run push:prod`, …
7+
#
8+
# You can optionally add `.env.<environment>.local` or `.env.local` for overrides
9+
# (see `src/config.ts`).
10+
#
11+
# Different Vapi organizations (dev vs prod workspaces) need different private API keys.
12+
# Create a separate file per environment and paste the private key for that org only.
13+
14+
# Required: Vapi private API key for the organization you are syncing to.
15+
VAPI_TOKEN=your-vapi-private-key-here
16+
17+
# Optional: defaults to https://api.vapi.ai if unset (use for local/API proxies only).
18+
# VAPI_BASE_URL=https://api.vapi.ai

AGENTS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This project manages **Vapi voice agent configurations** as code. All resources
44

55
**You do NOT need to know how Vapi works internally.** This guide tells you everything you need to author and modify resources.
66

7+
**Prompt quality:** Whenever you create a new assistant or change an existing assistant’s system prompt, read **`docs/Vapi Prompt Optimization Guide.md`** first. It goes deeper on structure, voice constraints, tool usage, and evaluation than the summary in this file.
8+
79
---
810

911
## Quick Reference
@@ -17,6 +19,8 @@ This project manages **Vapi voice agent configurations** as code. All resources
1719
| Create a multi-agent squad | Create `resources/squads/<name>.yml` |
1820
| Add post-call analysis | Create `resources/structuredOutputs/<name>.yml` |
1921
| Write test simulations | Create files under `resources/simulations/` |
22+
| Test webhook event delivery locally | Run `npm run mock:webhook` and tunnel with ngrok |
23+
| Track significant config updates | Update `docs/changelog.md` |
2024
| Push changes to Vapi | `npm run push:dev` or `npm run push:prod` |
2125
| Pull latest from Vapi | `npm run pull:dev` or `npm run pull:dev:force` |
2226
| Push only one file | `npm run push:dev resources/assistants/my-agent.md` |
@@ -27,6 +31,10 @@ This project manages **Vapi voice agent configurations** as code. All resources
2731
## Project Structure
2832

2933
```
34+
docs/
35+
├── Vapi Prompt Optimization Guide.md # In-depth prompt authoring (use when creating or editing assistants)
36+
└── changelog.md # Significant resource/config changes over time
37+
3038
resources/
3139
├── assistants/ # Voice agent definitions (.md or .yml)
3240
├── tools/ # Tool/function definitions (.yml)
@@ -37,6 +45,9 @@ resources/
3745
├── scenarios/ # Test case scripts (.yml)
3846
├── tests/ # Simulation runs (.yml)
3947
└── suites/ # Grouped simulation batches (.yml)
48+
49+
scripts/
50+
└── mock-vapi-webhook-server.ts # Local webhook receiver for server message testing
4051
```
4152

4253
---
@@ -601,6 +612,8 @@ The gitops engine resolves these local filenames to Vapi UUIDs automatically dur
601612

602613
The markdown body of an assistant `.md` file is the system prompt — the core instructions that define how the AI behaves on a call. This is the most important part to get right.
603614

615+
**Before drafting or changing prompts:** work through **`docs/Vapi Prompt Optimization Guide.md`** so structure, guardrails, and voice-specific habits stay consistent across agents.
616+
604617
### Recommended Structure
605618

606619
```markdown
@@ -670,6 +683,7 @@ npm run push:dev resources/assistants/my-agent.md # Push single file
670683
# Testing
671684
npm run call:dev -- -a <assistant-name> # Call an assistant via WebSocket
672685
npm run call:dev -- -s <squad-name> # Call a squad via WebSocket
686+
npm run mock:webhook # Run local webhook receiver for server message testing
673687
674688
# Build
675689
npm run build # Type-check
@@ -750,3 +764,13 @@ When transferring to human:
750764
3. Create simulations (pair personality + scenario)
751765
4. Create suites (batch simulations together)
752766
5. Run via Vapi dashboard or API
767+
768+
### Mock Server Testing (Webhook/Message Receipt)
769+
770+
If you need a local mock server to validate webhook payloads or message delivery behavior, you can add scripts under `/scripts` (for example: `scripts/mock-vapi-webhook-server.ts`) and run them locally during testing.
771+
772+
- Default expectation: no provider API key is needed for local receive-only mock testing.
773+
- If a provider-specific key is required, refer to the Vapi monorepo secrets workflow and use `dotenvx` to decrypt the needed values.
774+
- Assume decryption only works when the corresponding private keys are already available in your zsh environment.
775+
- For local webhook validation, prioritize core `serverMessages` event types such as `speech-update`, `status-update`, and `end-of-call-report`.
776+
- To test callbacks from Vapi into your local machine, expose the mock server with a tunnel like `ngrok` and use that public HTTPS URL in `assistant.server.url`.

CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Project Rules For Claude
2+
3+
This repository uses two instruction sources for Claude:
4+
5+
1. `AGENTS.md` is the primary, comprehensive guide for this codebase.
6+
2. `CLAUDE.md` contains Claude-specific reinforcement and policy reminders.
7+
8+
When both files exist, follow both. If guidance overlaps, treat `AGENTS.md` as the canonical project playbook and use this file to reinforce Claude-specific behavior.
9+
10+
## Required Reading Order
11+
12+
1. Read `AGENTS.md` first.
13+
2. Then read this file (`CLAUDE.md`) for additional policy constraints.
14+
15+
## Changelog Discipline
16+
17+
Always update `docs/changelog.md` when making significant configuration changes.
18+
19+
Significant changes include:
20+
- Assistant updates (prompt or YAML frontmatter)
21+
- Tool updates (new tools, changed parameters, changed behavior)
22+
- Squad updates (members, handoffs, overrides)
23+
- Other behavior-impacting resource changes (structured outputs, simulations)
24+
25+
Each changelog update should state:
26+
- Date (`YYYY-MM-DD`)
27+
- Files/resources changed
28+
- Why the change was made
29+
- Expected impact

README.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ Manage Vapi resources via Git using YAML/Markdown as the source-of-truth.
3737

3838
---
3939

40+
## How to Use This Repo
41+
42+
1. **Sync from Vapi first** using `pull` so local files reflect platform state.
43+
2. **Edit declarative resources** in `resources/` (`.md` assistants, `.yml` tools/squads/etc.).
44+
3. **Push selectively while iterating** (resource type or file path), then run a full push before release.
45+
4. **Promote by environment** (`dev` -> `stg` -> `prod`) using the same resource files with environment-specific state and credentials.
46+
47+
Use:
48+
- `pull` when Vapi might have changed
49+
- `push` for explicit deploys
50+
- `apply` (`pull -> merge -> push`) when you want one command for sync + deploy
51+
52+
---
53+
4054
## Quick Start
4155

4256
### Prerequisites
@@ -53,8 +67,13 @@ npm install
5367
### Setup Environment
5468

5569
```bash
56-
# Create your .env file with your Vapi token
57-
echo "VAPI_TOKEN=your-token-here" > .env.dev
70+
# Copy example values, then set real keys
71+
cp .env.example .env.dev
72+
cp .env.example .env.stg
73+
cp .env.example .env.prod
74+
75+
# Add the correct VAPI_TOKEN for each org/environment
76+
# Note: this repo uses .env.stg (not .env.staging)
5877
```
5978

6079
### Commands
@@ -63,33 +82,48 @@ echo "VAPI_TOKEN=your-token-here" > .env.dev
6382
|---------|-------------|
6483
| `npm run build` | Type-check the codebase |
6584
| `npm run pull:dev` | Pull platform state, preserve local changes |
85+
| `npm run pull:stg` | Pull staging state, preserve local changes |
6686
| `npm run pull:dev:force` | Pull platform state, overwrite everything |
87+
| `npm run pull:stg:force` | Pull staging state, overwrite everything |
6788
| `npm run pull:prod` | Pull from prod, preserve local changes |
6889
| `npm run pull:prod:force` | Pull from prod, overwrite everything |
6990
| `npm run push:dev` | Push local files to Vapi (dev) |
91+
| `npm run push:stg` | Push local files to Vapi (staging) |
7092
| `npm run push:prod` | Push local files to Vapi (prod) |
7193
| `npm run apply:dev` | Pull → Merge → Push in one shot (dev) |
94+
| `npm run apply:stg` | Pull → Merge → Push in one shot (staging) |
7295
| `npm run apply:prod` | Pull → Merge → Push in one shot (prod) |
7396
| `npm run push:dev assistants` | Push only assistants (dev) |
7497
| `npm run push:dev tools` | Push only tools (dev) |
7598
| `npm run call:dev -- -a <name>` | Start a WebSocket call to an assistant (dev) |
7699
| `npm run call:dev -- -s <name>` | Start a WebSocket call to a squad (dev) |
100+
| `npm run mock:webhook` | Run local webhook receiver for Vapi server messages |
77101

78102
### Basic Workflow
79103

80104
```bash
81-
# First time: pull all resources from Vapi
105+
# First time: pull all resources from Vapi for your target env
82106
npm run pull:dev:force
83107

84108
# Commit the initial state
85109
git add . && git commit -m "initial pull"
86110

87-
# Make changes to YAML/MD files...
111+
# Make changes to YAML/MD files under resources/
88112

89-
# Push changes to Vapi
113+
# Push your changes (full sync)
90114
npm run push:dev
91115
```
92116

117+
Promotion example:
118+
119+
```bash
120+
# After validating in dev, promote selectively to staging
121+
npm run push:stg resources/squads/your-squad.yml
122+
123+
# Promote to prod when ready
124+
npm run push:prod resources/squads/your-squad.yml
125+
```
126+
93127
#### Pulling Without Losing Local Work
94128

95129
By default, `pull` preserves any files you've locally modified or deleted:
@@ -193,12 +227,37 @@ If a dependency already exists on the platform (UUID in the state file) but its
193227

194228
This means you can work on everything in dev, then selectively push a single squad or assistant to staging or prod — no need for a full `push` that touches every resource.
195229

230+
### Webhook Local Testing
231+
232+
Use the local mock receiver when validating Vapi `serverMessages` delivery.
233+
234+
```bash
235+
# 1) Run local receiver
236+
npm run mock:webhook
237+
238+
# 2) Expose localhost (example)
239+
ngrok http 8787
240+
```
241+
242+
Then set your assistant `server.url` to the ngrok HTTPS URL and include event types like:
243+
- `speech-update`
244+
- `status-update`
245+
- `end-of-call-report`
246+
247+
The mock server exposes:
248+
- `POST /webhook` (or `POST /`)
249+
- `GET /health`
250+
- `GET /events`
251+
196252
---
197253

198254
## Project Structure
199255

200256
```
201257
vapi-gitops/
258+
├── docs/
259+
│ ├── Vapi Prompt Optimization Guide.md # Prompt authoring reference
260+
│ └── changelog.md # Significant change log
202261
├── src/
203262
│ ├── pull.ts # Pull platform state (with git stash/pop merge)
204263
│ ├── push.ts # Push local state to platform
@@ -222,9 +281,14 @@ vapi-gitops/
222281
│ ├── scenarios/ # Scenario YAML files
223282
│ ├── tests/ # Simulation YAML files
224283
│ └── suites/ # Simulation suite YAML files
284+
├── scripts/
285+
│ └── mock-vapi-webhook-server.ts # Local server message receiver
286+
├── .env.example # Example env var file
225287
├── .env.dev # Dev environment secrets (gitignored)
288+
├── .env.stg # Staging environment secrets (gitignored)
226289
├── .env.prod # Prod environment secrets (gitignored)
227290
├── .vapi-state.dev.json # Dev state file
291+
├── .vapi-state.stg.json # Staging state file
228292
└── .vapi-state.prod.json # Prod state file
229293
```
230294

0 commit comments

Comments
 (0)