技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
klaviyo-core-workflow-a【数据与研究】Execute Klaviyo primary workflow: profiles, lists, and subscriptions. Use when creating/updating profiles, managing lists, subscribing contacts, or syncing customer data to Klaviyo for email/SMS marketing. Trigger with phrases like "klaviyo profiles", "klaviyo lists", "klaviyo subscribe", "add contacts to klaviyo", "klaviyo customer data".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: klaviyo-core-workflow-a description: 'Execute Klaviyo primary workflow: profiles, lists, and subscriptions.
Use when creating/updating profiles, managing lists, subscribing contacts,
or syncing customer data to Klaviyo for email/SMS marketing.
Trigger with phrases like "klaviyo profiles", "klaviyo lists",
"klaviyo subscribe", "add contacts to klaviyo", "klaviyo customer data".
' allowed-tools: Read, Write, Edit, Bash(npm:*), Grep version: 1.7.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:
Primary money-path workflow: create/update profiles, manage lists, and subscribe contacts for email and SMS marketing via the klaviyo-api SDK. This skill covers the six-step path from a raw customer record to a consented, segmentable subscriber. High-level flow lives here; the full code for every step is in references/implementation.md.
klaviyo-install-auth setup so KLAVIYO_PRIVATE_KEY is available in the environment.profiles:read, profiles:write, lists:read, and lists:write.klaviyo-api npm package installed in the project (npm install klaviyo-api).Every call authenticates through a single ApiKeySession built from the private key:
import { ApiKeySession, ProfilesApi, ListsApi } from 'klaviyo-api';
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
const profilesApi = new ProfilesApi(session);
const listsApi = new ListsApi(session);
The workflow runs in six steps. Use the linked walkthrough for the complete code of each:
createOrUpdateProfile (upsert) over createProfile so re-syncs don't 409 on an existing email.listsApi.createList(...) returns the listId you use downstream; getLists() enumerates existing lists.createListRelationships adds membership only; it does NOT grant marketing consent.subscribeProfiles records email/SMS marketing consent with a consentTimestamp. This is the correct way to create real subscribers.getProfiles({ filter, sort }) supports equals, greater-than, and contains for segmentation.Full code for all six steps: references/implementation.md.
| Error | Status | Cause | Solution |
|---|---|---|---|
| Duplicate profile | 409 | Email exists | Use createOrUpdateProfile (upsert) |
| Invalid phone | 400 | Wrong format | Use E.164 format: +15551234567 |
| List not found | 404 | Wrong list ID | Verify list ID via getLists() |
| Missing consent | 400 | No consent timestamp | Always include consentTimestamp |
| Rate limited | 429 | >75 req/s burst | See klaviyo-rate-limits |
Three end-to-end scenarios that string the six steps into complete flows are in references/examples.md:
Minimal upsert-then-subscribe skeleton:
const upserted = await profilesApi.createOrUpdateProfile({
data: { type: ProfileEnum.Profile, attributes: { email: 'customer@example.com' } },
});
await profilesApi.subscribeProfiles({
data: {
type: 'profile-subscription-bulk-create-job',
attributes: { profiles: { data: [{ type: ProfileEnum.Profile, attributes: {
email: 'customer@example.com',
subscriptions: { email: { marketing: { consent: 'SUBSCRIBED', consentTimestamp: new Date().toISOString() } } },
} }] } },
relationships: { list: { data: { type: ListEnum.List, id: listId } } },
},
});
For event tracking and campaign triggers, see klaviyo-core-workflow-b. To harden against burst limits during bulk imports, see klaviyo-rate-limits.