@zellifyapp/mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/SKILL.md +47 -0
- package/build/client.d.ts +50 -0
- package/build/client.d.ts.map +1 -0
- package/build/client.js +49 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +65 -0
- package/build/prompts/integration-plan.d.ts +3 -0
- package/build/prompts/integration-plan.d.ts.map +1 -0
- package/build/prompts/integration-plan.js +117 -0
- package/build/tools/get-example-payload.d.ts +3 -0
- package/build/tools/get-example-payload.d.ts.map +1 -0
- package/build/tools/get-example-payload.js +48 -0
- package/build/tools/get-funnel-schema.d.ts +3 -0
- package/build/tools/get-funnel-schema.d.ts.map +1 -0
- package/build/tools/get-funnel-schema.js +53 -0
- package/build/tools/get-integrations.d.ts +3 -0
- package/build/tools/get-integrations.d.ts.map +1 -0
- package/build/tools/get-integrations.js +25 -0
- package/build/tools/list-funnels.d.ts +3 -0
- package/build/tools/list-funnels.d.ts.map +1 -0
- package/build/tools/list-funnels.js +20 -0
- package/build/tools/send-test-webhook.d.ts +3 -0
- package/build/tools/send-test-webhook.d.ts.map +1 -0
- package/build/tools/send-test-webhook.js +78 -0
- package/package.json +45 -0
- package/references/debugging.md +77 -0
- package/references/integration-paths.md +102 -0
- package/references/language-guides.md +87 -0
- package/references/revenuecat.md +73 -0
- package/references/types-and-payload.md +145 -0
- package/references/webhook-handler.md +67 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { sendTestWebhook } from "../client.js";
|
|
3
|
+
export function registerSendTestWebhook(server) {
|
|
4
|
+
server.tool("send_test_webhook", "Send a signed test webhook event to your configured endpoint. Returns response status, body, and timing. Payload includes context.test=true. Use to verify your handler works.", { funnelId: z.string().describe("The funnel ID (number as string)") }, async ({ funnelId }) => {
|
|
5
|
+
let data;
|
|
6
|
+
try {
|
|
7
|
+
data = await sendTestWebhook(funnelId);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
11
|
+
// Surface actionable messages for common failures
|
|
12
|
+
if (message.includes("404") || message.includes("not found")) {
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: `Funnel ${funnelId} not found. Run list_funnels to see available funnel IDs.`,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (message.includes("webhook") &&
|
|
23
|
+
(message.includes("not configured") || message.includes("no endpoint"))) {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: `No webhook endpoint configured. Go to Dashboard → Settings → Developers → Registration Webhook to set one up, then try again.`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
content: [
|
|
35
|
+
{ type: "text", text: `Test webhook failed: ${message}` },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const lines = [];
|
|
40
|
+
if (data.success) {
|
|
41
|
+
lines.push(`Webhook delivered successfully (${data.statusCode} in ${data.responseTimeMs}ms)`);
|
|
42
|
+
if (data.responseBody) {
|
|
43
|
+
lines.push("");
|
|
44
|
+
lines.push("Response body:");
|
|
45
|
+
lines.push(data.responseBody);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const error = data.error ?? "Unknown error";
|
|
50
|
+
// Enrich common error patterns
|
|
51
|
+
if (error.includes("ECONNREFUSED")) {
|
|
52
|
+
lines.push(`Webhook delivery failed: Connection refused. The endpoint server is not running or the port is wrong.`);
|
|
53
|
+
}
|
|
54
|
+
else if (error.includes("ENOTFOUND")) {
|
|
55
|
+
lines.push(`Webhook delivery failed: DNS resolution failed. Check the webhook URL for typos.`);
|
|
56
|
+
}
|
|
57
|
+
else if (error.includes("timeout") ||
|
|
58
|
+
error.includes("ETIMEDOUT")) {
|
|
59
|
+
lines.push(`Webhook delivery failed: Timeout (>10s). The handler must respond within 10 seconds — move heavy processing to a background job.`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
lines.push(`Webhook delivery failed: ${error}`);
|
|
63
|
+
}
|
|
64
|
+
if (data.responseTimeMs !== undefined) {
|
|
65
|
+
lines.push(`(after ${data.responseTimeMs}ms)`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
lines.push("");
|
|
69
|
+
lines.push("---");
|
|
70
|
+
lines.push("Payload sent:");
|
|
71
|
+
lines.push("```json");
|
|
72
|
+
lines.push(JSON.stringify(data.payloadSent, null, 2));
|
|
73
|
+
lines.push("```");
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zellifyapp/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An MCP server that gives Claude Code full context about your Zellify funnels so it can build, test, and debug your webhook integration.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"zellify-mcp": "./build/index.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"mcp",
|
|
11
|
+
"claude",
|
|
12
|
+
"claude-code",
|
|
13
|
+
"zellify",
|
|
14
|
+
"webhook"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/Zellify/web2app-rebuild.git",
|
|
19
|
+
"directory": "packages/zellify-mcp"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "pnpm run clean && tsc && chmod 755 build/index.js",
|
|
23
|
+
"clean": "rimraf build tsconfig.tsbuildinfo",
|
|
24
|
+
"clean:deep": "rimraf build node_modules .turbo tsconfig.tsbuildinfo",
|
|
25
|
+
"check-types": "tsc --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"build",
|
|
29
|
+
"SKILL.md",
|
|
30
|
+
"references"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
34
|
+
"zod": "^3.25.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.15.3",
|
|
38
|
+
"@web2app/typescript-config": "workspace:*",
|
|
39
|
+
"rimraf": "^6.0.1",
|
|
40
|
+
"typescript": "5.9.2"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Debugging Webhook Issues
|
|
2
|
+
|
|
3
|
+
## Step 1: Is the webhook configured?
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
get_integrations → check for registration_webhook
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
If not configured: Dashboard → Settings → Developers → Registration Webhook → Configure.
|
|
10
|
+
|
|
11
|
+
## Step 2: Are they testing in preview mode?
|
|
12
|
+
|
|
13
|
+
Any URL containing `/preview/` silently disables ALL webhooks. The preview tracker is a complete stub — every method is a no-op. No warning in the UI.
|
|
14
|
+
|
|
15
|
+
Fix: Use the live funnel URL (`yourdomain.com/f/{funnelId}/...`), or use `send_test_webhook`.
|
|
16
|
+
|
|
17
|
+
## Step 3: Fire a test webhook
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
send_test_webhook(funnelId)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Generates a realistic payload from the funnel's schema, signs it, POSTs to their endpoint.
|
|
24
|
+
|
|
25
|
+
## Response diagnosis
|
|
26
|
+
|
|
27
|
+
### No response / connection error
|
|
28
|
+
|
|
29
|
+
- Connection refused → server not running, wrong port, firewall
|
|
30
|
+
- DNS resolution failed → check URL for typos
|
|
31
|
+
- Timeout (>10s) → move heavy processing to background job
|
|
32
|
+
- SSL/TLS error → check cert validity
|
|
33
|
+
|
|
34
|
+
### HTTP error responses
|
|
35
|
+
|
|
36
|
+
| Status | Likely cause | Fix |
|
|
37
|
+
|--------|-------------|-----|
|
|
38
|
+
| 400 | Expects wrong payload shape | Common: expecting flat answers instead of `{ value }` objects, or expecting fields that don't exist |
|
|
39
|
+
| 401/403 | Auth middleware blocking OR signature mismatch | Exclude webhook route from auth; verify raw body for signatures |
|
|
40
|
+
| 404 | URL doesn't match route | Check webhook config URL matches route definition |
|
|
41
|
+
| 405 | Route defined as GET instead of POST | Change to POST |
|
|
42
|
+
| 500 | Bug in handler code | Check server logs for stack trace |
|
|
43
|
+
|
|
44
|
+
### 200 but nothing happens
|
|
45
|
+
|
|
46
|
+
- **Checking for event type field:** Registration Webhook has no `event` or `type` field. It always represents email_captured. Handlers that route by event type silently exit.
|
|
47
|
+
- **Accessing answers incorrectly:** Accessing `payload.answers.gender` expecting a string but getting `{ value: "1", label: "Male" }`. Use `.label` or `.value`.
|
|
48
|
+
- **Email dedup:** Test email already exists, handler skips processing.
|
|
49
|
+
- **Wrong environment:** Handler writes to staging DB they're not checking.
|
|
50
|
+
|
|
51
|
+
### Signature verification failures
|
|
52
|
+
|
|
53
|
+
Most common cause: **parsing the body before verifying.** `JSON.parse(body)` then `JSON.stringify(parsed)` changes whitespace/key ordering.
|
|
54
|
+
|
|
55
|
+
Fix: Capture raw request body BEFORE parsing. See `references/language-guides.md`.
|
|
56
|
+
|
|
57
|
+
Other causes: wrong secret (regenerated but env var not updated), encoding mismatch (UTF-8 vs Latin-1).
|
|
58
|
+
|
|
59
|
+
## Step 4: End-to-end with real funnel
|
|
60
|
+
|
|
61
|
+
After test webhook passes:
|
|
62
|
+
1. Open live funnel URL in incognito browser
|
|
63
|
+
2. Fill out the quiz, submit email
|
|
64
|
+
3. Check server logs / database for the new record
|
|
65
|
+
|
|
66
|
+
If test works but real funnel doesn't fire:
|
|
67
|
+
- Funnel may not be published (check `list_funnels`)
|
|
68
|
+
- Email capture component may not be on the page they're testing
|
|
69
|
+
- Ad blockers may block the tracking script
|
|
70
|
+
|
|
71
|
+
## Webhook delivery facts
|
|
72
|
+
|
|
73
|
+
- Method: POST, Content-Type: application/json
|
|
74
|
+
- Signature: X-Webhook-Signature (HMAC-SHA256)
|
|
75
|
+
- Timeout: 10 seconds, Retries: none
|
|
76
|
+
- No delivery logs in dashboard
|
|
77
|
+
- `context.test: true` only on MCP test events
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Integration Paths
|
|
2
|
+
|
|
3
|
+
Use `get_integrations` to determine which path fits the developer.
|
|
4
|
+
|
|
5
|
+
## How to pick
|
|
6
|
+
|
|
7
|
+
| They have... | Path |
|
|
8
|
+
|-------------|------|
|
|
9
|
+
| Mobile app + RevenueCat | Mobile App with RevenueCat |
|
|
10
|
+
| Mobile app + own backend | Mobile App with Custom Backend |
|
|
11
|
+
| Web app, users need accounts | Web App with Signup Page |
|
|
12
|
+
| Existing Stripe/Paddle webhook handlers | Using Existing Webhooks |
|
|
13
|
+
| Need accounts before payment | Early Account Creation |
|
|
14
|
+
| No paywall, just onboarding | Free Funnel with Deep Link |
|
|
15
|
+
| Custom success page logic | Custom Registration Component |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Mobile App with RevenueCat
|
|
20
|
+
|
|
21
|
+
**Needs:** RevenueCat connected to Stripe/Paddle, deep link on success page, SDK init with app_user_id.
|
|
22
|
+
|
|
23
|
+
**app_user_id chain (3 places):**
|
|
24
|
+
1. Stripe/Paddle metadata → read by RevenueCat via S2S webhook
|
|
25
|
+
2. Deep Link Button URL → carried into the app
|
|
26
|
+
3. RevenueCat SDK init → `Purchases.configure()` with app_user_id from deep link
|
|
27
|
+
|
|
28
|
+
**Biggest risk:** 5 silent failure points — see `references/revenuecat.md`.
|
|
29
|
+
|
|
30
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/mobile-app-revenuecat
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Mobile App with Custom Backend
|
|
35
|
+
|
|
36
|
+
**Needs:** Payment webhook handler (Stripe/Paddle), deep link on success page. Optionally Registration Webhook for early lead capture.
|
|
37
|
+
|
|
38
|
+
**app_user_id chain (2 places):**
|
|
39
|
+
1. Stripe/Paddle metadata → in the payment webhook
|
|
40
|
+
2. Deep Link Button URL → carried into the app
|
|
41
|
+
|
|
42
|
+
**Stripe events to listen for:**
|
|
43
|
+
|
|
44
|
+
| Scenario | Event |
|
|
45
|
+
|----------|-------|
|
|
46
|
+
| One-time product | `checkout.session.completed` |
|
|
47
|
+
| Subscription (first) | `checkout.session.completed` |
|
|
48
|
+
| Subscription (renewals) | `invoice.paid` |
|
|
49
|
+
| Upsells | `invoice.paid` |
|
|
50
|
+
|
|
51
|
+
Recommend listening for both events. Use idempotency on app_user_id.
|
|
52
|
+
|
|
53
|
+
**Paddle:** Listen for `transaction.completed`. Paddle does NOT support upsells or multi-phase subscription schedules.
|
|
54
|
+
|
|
55
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/mobile-app-custom-backend
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Web App with Signup Page
|
|
60
|
+
|
|
61
|
+
**Needs:** Registration Webhook handler, redirect URL on success page with `app_user_id` + `email` as URL parameters.
|
|
62
|
+
|
|
63
|
+
**Flow:** Funnel → pay → success page → button redirects to `https://app.example.com/signup?userId={{app_user_id}}&email={{email}}` → web app creates account.
|
|
64
|
+
|
|
65
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/web-app-signup-page
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Using Existing Webhooks
|
|
70
|
+
|
|
71
|
+
Developer already has Stripe/Paddle webhook handlers. Zellify sets `app_user_id` in Stripe `customer.metadata` and `subscription.metadata`, or Paddle `customer.custom_data` and `transaction.custom_data`. Developer reads this field in their existing handlers.
|
|
72
|
+
|
|
73
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/existing-webhook-provisioning
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Early Account Creation
|
|
78
|
+
|
|
79
|
+
Registration Webhook creates a pending account BEFORE payment. Payment webhook activates it.
|
|
80
|
+
|
|
81
|
+
1. Email submitted → Registration Webhook → create pending account with app_user_id
|
|
82
|
+
2. Payment → Stripe/Paddle webhook → look up by app_user_id → activate
|
|
83
|
+
|
|
84
|
+
Same app_user_id links both events. Handle the case where payment never happens.
|
|
85
|
+
|
|
86
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/early-account-creation
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Free Funnel with Deep Link
|
|
91
|
+
|
|
92
|
+
No paywall, no checkout. Registration Webhook is the ONLY data delivery mechanism.
|
|
93
|
+
|
|
94
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/free-funnel-deeplink
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Custom Registration Component
|
|
99
|
+
|
|
100
|
+
Client-side code on the success page that calls the developer's API from the browser. Has access to app_user_id, email, and quiz answers via Zellify runtime variables. Developer must handle CORS and browser close before completion.
|
|
101
|
+
|
|
102
|
+
**Docs:** https://docs.zellify.app/integrate-with-zellify/integration-guides/custom-registration-component
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Language-Specific Patterns
|
|
2
|
+
|
|
3
|
+
The two Zellify-specific things Claude doesn't know per framework: (1) how to capture the raw HTTP body before parsing, and (2) the answer `.value` / `.label` access pattern.
|
|
4
|
+
|
|
5
|
+
## Raw body capture patterns
|
|
6
|
+
|
|
7
|
+
### Express
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// On the webhook route — NOT express.json()
|
|
11
|
+
app.post('/webhooks/zellify',
|
|
12
|
+
express.raw({ type: 'application/json' }),
|
|
13
|
+
(req, res) => {
|
|
14
|
+
const rawBody = req.body.toString('utf-8');
|
|
15
|
+
// verify signature against rawBody, then JSON.parse(rawBody)
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
If `express.json()` is global, use the `verify` callback:
|
|
21
|
+
```typescript
|
|
22
|
+
app.use(express.json({
|
|
23
|
+
verify: (req, _res, buf) => { (req as any).rawBody = buf.toString('utf-8'); }
|
|
24
|
+
}));
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Fastify
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
fastify.addContentTypeParser('application/json', { parseAs: 'string' },
|
|
31
|
+
(req, body, done) => { done(null, body); }
|
|
32
|
+
);
|
|
33
|
+
// request.body is now the raw string
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Flask
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
raw_body = request.get_data(as_text=True) # NOT request.json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Django
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
raw_body = request.body.decode('utf-8')
|
|
46
|
+
# Requires @csrf_exempt on the webhook view
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Go
|
|
50
|
+
|
|
51
|
+
```go
|
|
52
|
+
rawBody, _ := io.ReadAll(r.Body)
|
|
53
|
+
// r.Body is already raw bytes
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Rails
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
raw_body = request.raw_post
|
|
60
|
+
# Requires skip_before_action :verify_authenticity_token
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Vercel Serverless
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
export const config = { api: { bodyParser: false } };
|
|
67
|
+
// Manually collect chunks from req
|
|
68
|
+
const chunks: Buffer[] = [];
|
|
69
|
+
for await (const chunk of req) chunks.push(chunk);
|
|
70
|
+
const rawBody = Buffer.concat(chunks).toString('utf-8');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### AWS Lambda
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// event.body is already raw string
|
|
77
|
+
const rawBody = event.body ?? '';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Answer access pattern (all languages)
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
answer.label → "Male" (use when present — singleselect, slider)
|
|
84
|
+
answer.value → "1" (option ID — always present)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For multiselect, `value` is an array of option IDs. Resolve each via a lookup map from `get_funnel_schema`.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# RevenueCat Integration
|
|
2
|
+
|
|
3
|
+
## The chain
|
|
4
|
+
|
|
5
|
+
Every link must be correct. A failure at any point is silent.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Zellify funnel → quiz → paywall
|
|
9
|
+
→ Checkout: Zellify sets app_user_id in Stripe/Paddle metadata
|
|
10
|
+
→ Payment: Stripe/Paddle charges the visitor
|
|
11
|
+
→ S2S webhook: Stripe/Paddle → RevenueCat
|
|
12
|
+
→ RevenueCat reads app_user_id from metadata → creates subscriber
|
|
13
|
+
→ Success page: Deep Link Button interpolates app_user_id into URL
|
|
14
|
+
→ App opens, extracts app_user_id from deep link
|
|
15
|
+
→ App calls Purchases.configure() with app_user_id
|
|
16
|
+
→ RevenueCat returns entitlements → access granted
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 5 silent failure points
|
|
20
|
+
|
|
21
|
+
### 1. "Track new purchases" toggle is OFF
|
|
22
|
+
|
|
23
|
+
- **Where:** RevenueCat dashboard → app → Stripe/Paddle integration settings
|
|
24
|
+
- **Default:** OFF
|
|
25
|
+
- **Symptom:** Stripe sends webhooks, RevenueCat responds 200, but no subscriber is created. Nothing errors anywhere.
|
|
26
|
+
- **Fix:** Enable "Track new purchases from server-to-server notifications"
|
|
27
|
+
- **Cannot be verified via API.** Must be checked manually in RevenueCat dashboard.
|
|
28
|
+
|
|
29
|
+
### 2. Wrong app_user_id detection method
|
|
30
|
+
|
|
31
|
+
- **Where:** RevenueCat dashboard → Stripe/Paddle integration → App User ID detection method
|
|
32
|
+
- **Correct:** "Read from Stripe metadata" or "Read from Paddle custom data"
|
|
33
|
+
- **Symptom:** Subscriber created with wrong ID (e.g., Stripe `cus_xxx` instead of Zellify app_user_id). App initializes SDK with the Zellify ID, finds no subscriber.
|
|
34
|
+
- **Cannot be verified via API.**
|
|
35
|
+
|
|
36
|
+
### 3. Products not mapped to entitlements
|
|
37
|
+
|
|
38
|
+
- **Where:** RevenueCat dashboard → Products → Entitlements
|
|
39
|
+
- **Symptom:** Subscriber profile exists, purchase tracked, but no entitlements granted. App checks entitlements, finds none.
|
|
40
|
+
- **Fix:** Map each Stripe/Paddle product ID to a RevenueCat entitlement.
|
|
41
|
+
|
|
42
|
+
### 4. app_user_id missing from deep link
|
|
43
|
+
|
|
44
|
+
- **Where:** Zellify funnel editor → success page → Deep Link Button configuration
|
|
45
|
+
- **Symptom:** App opens but has no app_user_id. SDK initializes with anonymous ID. Entitlements exist on a different subscriber profile.
|
|
46
|
+
- **Fix:** Enable app_user_id interpolation: `yourapp://open?userId={{app_user_id}}`
|
|
47
|
+
|
|
48
|
+
### 5. App doesn't use app_user_id from deep link
|
|
49
|
+
|
|
50
|
+
- **Where:** Developer's mobile app code
|
|
51
|
+
- **Symptom:** App receives deep link but ignores app_user_id. SDK starts anonymous.
|
|
52
|
+
- **Fix:** Extract app_user_id from deep link URL and pass to `Purchases.configure()` or `Purchases.logIn()`.
|
|
53
|
+
|
|
54
|
+
## Zellify's RevenueCat metadata enrichment
|
|
55
|
+
|
|
56
|
+
When enabled (Dashboard → Settings → Integrations → RevenueCat), Zellify calls RevenueCat's API at checkout time to pre-create a subscriber profile with email, funnel/campaign/experiment metadata as subscriber attributes. This is optional but valuable — the Stripe/Paddle S2S webhook does NOT carry email.
|
|
57
|
+
|
|
58
|
+
Check if enabled: `get_integrations` → look for `revenuecat: configured`.
|
|
59
|
+
|
|
60
|
+
## Diagnosis workflow
|
|
61
|
+
|
|
62
|
+
1. `get_integrations` — verify RevenueCat + payment provider configured
|
|
63
|
+
2. Ask developer to check points 1 and 2 in RevenueCat dashboard (no API access)
|
|
64
|
+
3. Verify product → entitlement mapping
|
|
65
|
+
4. Check deep link button configuration in funnel editor
|
|
66
|
+
5. Review app's deep link handling and SDK initialization code
|
|
67
|
+
|
|
68
|
+
## Reference docs
|
|
69
|
+
|
|
70
|
+
- Zellify RevenueCat guide: https://docs.zellify.app/integrate-with-zellify/integration-guides/mobile-app-revenuecat
|
|
71
|
+
- Zellify RevenueCat settings: https://docs.zellify.app/platform-introduction/integrations/revenuecat
|
|
72
|
+
- RevenueCat Stripe setup: https://www.revenuecat.com/docs/web/integrations/stripe
|
|
73
|
+
- RevenueCat identifying users: https://www.revenuecat.com/docs/customers/user-ids
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Types and Payload Format
|
|
2
|
+
|
|
3
|
+
## Payload structure
|
|
4
|
+
|
|
5
|
+
The Registration Webhook sends this JSON structure:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"email": "user@example.com",
|
|
10
|
+
"answers": {
|
|
11
|
+
"nickname": { "value": "example" },
|
|
12
|
+
"age": { "value": 50 },
|
|
13
|
+
"gender": { "value": "1", "label": "Male" },
|
|
14
|
+
"favoriteActivities": { "value": ["1", "3"] }
|
|
15
|
+
},
|
|
16
|
+
"context": {
|
|
17
|
+
"appUserId": "ac17064d-4edf-5acc-8487-d8dd4e5b1ac5",
|
|
18
|
+
"funnelId": "46",
|
|
19
|
+
"campaignId": "12",
|
|
20
|
+
"experimentId": "33",
|
|
21
|
+
"experimentTag": "variant-a",
|
|
22
|
+
"organizationId": "529719da-d8e7-4c36-ae52-1cf9f6630c39",
|
|
23
|
+
"pageLocation": "/f/46/page-2",
|
|
24
|
+
"ip": "95.104.11.250",
|
|
25
|
+
"userAgent": "Mozilla/5.0 ...",
|
|
26
|
+
"sessionToken": "eyJ..."
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Answer format
|
|
32
|
+
|
|
33
|
+
Each answer is an object with `value` and optionally `label`, `pageSlug`, `questionText`:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
CORRECT: "gender": { "value": "1", "label": "Male" }
|
|
37
|
+
WRONG: "gender": "1"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**IMPORTANT:** Use `answer.label` as the primary way to get human-readable text. Generate lookup maps from `get_funnel_schema` only when `label` is absent. Not all answer types include `label` — number and text types typically don't.
|
|
41
|
+
|
|
42
|
+
## Answer value types (inside the wrapper)
|
|
43
|
+
|
|
44
|
+
| Question type | Type of `value` | `label` included? | Example |
|
|
45
|
+
|--------------|-----------------|-------------------|---------|
|
|
46
|
+
| text | string | no | `{ "value": "John" }` |
|
|
47
|
+
| email | string | no | `{ "value": "user@example.com" }` |
|
|
48
|
+
| number | number | no | `{ "value": 25 }` |
|
|
49
|
+
| singleselect | string (option ID) | yes | `{ "value": "1", "label": "Male" }` |
|
|
50
|
+
| multiselect | string[] (option IDs) | no (per-ID) | `{ "value": ["1", "3"] }` |
|
|
51
|
+
| slider | string (option ID) | yes | `{ "value": "2", "label": "Medium" }` |
|
|
52
|
+
| range | string ("from-to") | no | `{ "value": "18-35" }` |
|
|
53
|
+
|
|
54
|
+
**Option IDs are not labels.** Singleselect value `"1"` is opaque. Resolve via `answer.label` or `get_funnel_schema`.
|
|
55
|
+
|
|
56
|
+
## Context fields
|
|
57
|
+
|
|
58
|
+
| Field | Type | Description |
|
|
59
|
+
|-------|------|-------------|
|
|
60
|
+
| appUserId | string | Zellify session ID. Same value in Stripe/Paddle metadata as `app_user_id` |
|
|
61
|
+
| funnelId | string | Funnel where registration occurred |
|
|
62
|
+
| campaignId | string | Campaign link the visitor used |
|
|
63
|
+
| experimentId | string? | A/B test experiment ID (only when experiments are active) |
|
|
64
|
+
| experimentTag | string? | A/B experiment variant tag (only when experiments are active) |
|
|
65
|
+
| organizationId | string | Organization that owns the funnel |
|
|
66
|
+
| pageLocation | string | Page path where registration happened |
|
|
67
|
+
| ip | string | Visitor's IP address |
|
|
68
|
+
| userAgent | string | Visitor's browser user agent |
|
|
69
|
+
| sessionToken | string? | Session token (internal use) |
|
|
70
|
+
|
|
71
|
+
**`context.test`** is `true` ONLY on test events sent via `send_test_webhook` (MCP tool). Real webhook deliveries never include this field.
|
|
72
|
+
|
|
73
|
+
## Generating TypeScript types
|
|
74
|
+
|
|
75
|
+
Use `get_funnel_schema` and `get_example_payload` to generate accurate types.
|
|
76
|
+
|
|
77
|
+
### Base types (same for every funnel)
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
interface ZellifyContext {
|
|
81
|
+
appUserId: string;
|
|
82
|
+
funnelId: string;
|
|
83
|
+
campaignId: string;
|
|
84
|
+
experimentId?: string;
|
|
85
|
+
experimentTag?: string;
|
|
86
|
+
organizationId: string;
|
|
87
|
+
pageLocation: string;
|
|
88
|
+
ip: string;
|
|
89
|
+
userAgent: string;
|
|
90
|
+
sessionToken?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface ZellifyWebhookPayload {
|
|
94
|
+
email: string;
|
|
95
|
+
answers: ZellifyAnswers; // funnel-specific, generated below
|
|
96
|
+
context: ZellifyContext;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Funnel-specific answers type
|
|
101
|
+
|
|
102
|
+
For each variable in the schema, generate a wrapper with the appropriate type. Include `label` for select types:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
/** Option: "1" = Male, "2" = Female */
|
|
106
|
+
type GenderOption = "1" | "2";
|
|
107
|
+
|
|
108
|
+
interface ZellifyAnswers {
|
|
109
|
+
gender: { value: GenderOption; label?: string };
|
|
110
|
+
age: { value: number };
|
|
111
|
+
favoriteActivities: { value: string[] };
|
|
112
|
+
goal: { value: string };
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Zod schema (if developer uses Zod)
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { z } from 'zod';
|
|
120
|
+
|
|
121
|
+
const answerValue = <T extends z.ZodType>(inner: T) =>
|
|
122
|
+
z.object({ value: inner, label: z.string().optional() });
|
|
123
|
+
|
|
124
|
+
const zellifyPayloadSchema = z.object({
|
|
125
|
+
email: z.string().email(),
|
|
126
|
+
answers: z.object({
|
|
127
|
+
gender: answerValue(z.enum(["1", "2"])),
|
|
128
|
+
age: answerValue(z.number()),
|
|
129
|
+
favoriteActivities: answerValue(z.array(z.string())),
|
|
130
|
+
goal: answerValue(z.string()),
|
|
131
|
+
}),
|
|
132
|
+
context: z.object({
|
|
133
|
+
appUserId: z.string(),
|
|
134
|
+
funnelId: z.string(),
|
|
135
|
+
campaignId: z.string(),
|
|
136
|
+
experimentId: z.string().optional(),
|
|
137
|
+
experimentTag: z.string().optional(),
|
|
138
|
+
organizationId: z.string(),
|
|
139
|
+
pageLocation: z.string(),
|
|
140
|
+
ip: z.string(),
|
|
141
|
+
userAgent: z.string(),
|
|
142
|
+
sessionToken: z.string().optional(),
|
|
143
|
+
}),
|
|
144
|
+
});
|
|
145
|
+
```
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Building a Registration Webhook Handler
|
|
2
|
+
|
|
3
|
+
## Step 1: Gather funnel-specific data
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
list_funnels → pick the published funnel
|
|
7
|
+
get_funnel_schema(funnelId) → variable names, types, option ID → label mappings
|
|
8
|
+
get_example_payload(funnelId) → exact payload shape + TypeScript interface
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**MUST call these before generating a handler.** Variable names, types, and options are specific to each funnel.
|
|
12
|
+
|
|
13
|
+
## Step 2: Generate the handler
|
|
14
|
+
|
|
15
|
+
Every handler MUST include these Zellify-specific elements:
|
|
16
|
+
|
|
17
|
+
### Signature verification (never skip, even for testing)
|
|
18
|
+
|
|
19
|
+
Verify `X-Webhook-Signature` header against `HMAC-SHA256(secret, raw_body)`. **IMPORTANT:** Use the raw request body as-is — do not parse then re-stringify. See `references/language-guides.md` for the raw-body capture pattern in each language/framework.
|
|
20
|
+
|
|
21
|
+
### Answer access pattern
|
|
22
|
+
|
|
23
|
+
**IMPORTANT:** Use `answer.label` as the primary pattern — it gives the human-readable label directly:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const gender = payload.answers.gender.label; // "Male"
|
|
27
|
+
const age = payload.answers.age.value; // 50 (number types have no label)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Fall back to lookup maps from `get_funnel_schema` only when `label` is missing. For multiselect, each option ID needs resolution — generate a lookup map:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
const ACTIVITY_LABELS: Record<string, string> = { "1": "Play", "2": "Dance" };
|
|
34
|
+
const labels = payload.answers.activities.value.map(id => ACTIVITY_LABELS[id]);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Typed payload interface
|
|
38
|
+
|
|
39
|
+
Generate from `get_example_payload`. Use the developer's actual variable names. Each answer is a `{ value: T, label?: string }` object.
|
|
40
|
+
|
|
41
|
+
### Store context.appUserId
|
|
42
|
+
|
|
43
|
+
Always persist `context.appUserId` alongside the email — this is the key for matching with payment events later.
|
|
44
|
+
|
|
45
|
+
## Step 3: Test
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
send_test_webhook(funnelId)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Test payloads include `context.test: true` (only on MCP-sent test events, never on real deliveries).
|
|
52
|
+
|
|
53
|
+
Diagnosis:
|
|
54
|
+
- 200 + expected body → success
|
|
55
|
+
- Non-200 → check error response and server logs
|
|
56
|
+
- No response → endpoint unreachable (see `references/debugging.md`)
|
|
57
|
+
- 401 with "signature mismatch" → raw body issue
|
|
58
|
+
|
|
59
|
+
## Step 4: Production checklist
|
|
60
|
+
|
|
61
|
+
- [ ] Signature verification on raw body (not re-serialized JSON)
|
|
62
|
+
- [ ] Webhook secret in environment variable
|
|
63
|
+
- [ ] Handler responds within 10 seconds (defer heavy work)
|
|
64
|
+
- [ ] Handler is idempotent (duplicate emails don't create duplicates)
|
|
65
|
+
- [ ] Answer values accessed via `.label` or `.value` (never flat)
|
|
66
|
+
- [ ] context.appUserId stored for payment event matching
|
|
67
|
+
- [ ] No retries — handle failures with logging/alerting on your side
|