Crepal — AI Video Creator Skill
Overview
Crepal is a one-stop AI video creation tool. This skill connects OpenClaw to CrePal's API so you can create videos through natural conversation.
Ground Rules
These apply to everything you do with this skill.
- Never show raw technical output to the user. No JSON, no session IDs, no HTTP codes, no function-call names, no
[CREPAL_CALLBACK]content. Summarize in plain, friendly language — as if texting a friend. - Never stay silent after receiving an
agentMsg. Always either reply to CrePal or callconfirm_generate— except after Step 3 polling completes, where you skip the Decision Tree and go straight to Step 4 (download). - The
confirm_generateAPI is the ONLY way to start video rendering. Sending a chat message like "please generate" does nothing. You must call the dedicated endpoint. - Translate errors into actionable advice. Instead of
HTTP 401, say "Your API token seems invalid — could you double-check it?" - Keep progress updates to one sentence. e.g. "CrePal 问了视频风格,我帮你选了温馨的,正在继续…"
Configuration — metadata.json
Stored in the skill root directory. Read it on every invocation.
{
"api_key": "",
"user_channel": "",
"auto_pilot": false,
"last_session_id": ""
}| Field | Purpose |
|---|---|
api_key | CrePal API token. Used as Authorization: Bearer <api_key>. |
user_channel | User's messaging address (e.g. telegram:123456789). Required for callbacks & notifications. |
auto_pilot | true = full automation; false = step-by-step with user approval. |
last_session_id | Most recent session ID for easy resumption. |
First-Run Setup
If api_key, user_channel, or both are empty:
- Welcome the user — introduce CrePal briefly.
- Collect
user_channel— ask for their messaging platform address (platform:id). This is mandatory; without it, callbacks cannot be delivered. - Collect
api_key— direct them to crepal.ai to get a token. - Ask about auto-pilot — explain the two modes and store their choice.
- Write all values to
metadata.jsonimmediately.
Pre-flight (every invocation): If user_channel or api_key is empty → ask before doing anything else.
Auto-Pilot Mode
Active when auto_pilot is true, or the user explicitly asks for full automation. You complete the entire pipeline without pausing for user input.
⚠️ Execution Model — FOREGROUND, NOT BACKGROUND
You MUST run ALL Python scripts (poll_session.py AND poll_download.py) in the foreground (i.e. background: false or simply exec). Wait for them to finish and capture stdout. Do NOT use background: true — background mode causes OpenClaw to dump raw script output into the user's chat, and the agent never gets a chance to process it.
poll_session.pyoutputs only theagentMsgtext to stdout.poll_download.pyoutputs only theresultUrlto stdout.- Both scripts send debug info to stderr only.
- Non-zero exit code = error. Tell the user in friendly language; do NOT show raw error output.
You capture stdout, process it, and act on it — all in the same turn.
Step 1 — Create Session & Poll
POST /api/openclaw/chat/session/createwith the user's video description ascontent.- Save
sessionId→metadata.json→last_session_id. - Tell the user briefly: "正在和 CrePal 沟通你的视频需求,请稍等…"
- Run
poll_session.pyin FOREGROUND (no--callback, no--notify):python3 scripts/poll_session.py "https://crepal.ai" "<TOKEN>" "<SID>" - Check exit code: non-zero → tell user "和 CrePal 通信时遇到了问题,请检查网络或 API token。" Stop.
- Capture stdout — it contains only the
agentMsgtext from CrePal. - Go to Step 2 with the captured
agentMsg.
Step 2 — Process agentMsg (SILENT & IMMEDIATE)
You now have the agentMsg text. Do NOT show it raw to the user. Classify it and act:
Case A — Credit Error
agentMsg mentions "insufficient credits", "余额不足", etc. → Exit auto-pilot. Go to Recharge workflow.
Case B — Script Ready → CALL confirm_generate NOW 🔴
Match if ANY of these are true:
- Keywords: "generate", "render", "ready to produce", "开始生成", "准备生成", "是否生成视频"
- Script is "confirmed", "finalized", "complete", "done", "完成", "确认"
- CrePal says "anything else?", "want to proceed?", "shall I continue?" after a script
- 3+ rounds have passed and no new questions in the latest
agentMsg - You replied "looks good" last round and no new questions came back
→ IMMEDIATELY go to Step 3. Do NOT reply via message/send. Call the confirm_generate API right now.
⚠️ When in doubt between B and C/D, always choose B. Better to generate early than loop forever.
Case C — CrePal Asks a Question
agentMsg asks a question or offers choices (e.g. "What style?", "(A)... (B)..."). → Compose a direct answer based on the user's original description. Send via message/send. Then re-poll (go to Step 2½).
Case D — Script Draft Needs Feedback
agentMsg shows a draft and asks "what do you think?" → Reply "Looks great, please continue" via message/send. Then re-poll.
Case E — Anything Else
→ Reply "Looks good, please continue" via message/send. Then re-poll. Never stay silent.
Step 2½ — Re-poll After Reply (Cases C/D/E)
After sending a reply to CrePal:
- Tell the user in one friendly sentence what you did (e.g. "我帮你选了温馨风格,正在等 CrePal 回复…").
- Run
poll_session.pyin FOREGROUND again (same command as Step 1, no flags). - Capture stdout → go back to Step 2 with the new
agentMsg. - Repeat until you reach Case A or B.
🛑 LOOP GUARD: If you've been through 3+ rounds and the latest agentMsg has no clear new questions → treat it as Case B and call confirm_generate.
✅ YIELD SELF-CHECK (mandatory before every turn ends)
Before you finish a turn or yield control back to the user, ask yourself:
"Have I already called confirm_generate for this session?"- No, and a script/draft has been discussed → You probably missed Case B. Go to Step 3 NOW.
- No, but CrePal is still asking questions → Fine, continue the loop.
- Yes → Continue to Step 4 (or you're done).
This check prevents the most common failure mode: the agent replies to CrePal in a loop but never actually triggers video generation.
Step 3 — Confirm & Generate 🔴
This step starts video rendering. Without it, the user gets nothing.
POST /api/openclaw/script/confirm_generatewith{"sessionId": "..."}. This is a dedicated API call — NOT a chat message viamessage/send.- Tell the user: "剧本已确认,视频片段正在生成中,请稍等…"
- Run
poll_session.pyin FOREGROUND to wait for rendering to finish:python3 scripts/poll_session.py "https://crepal.ai" "<TOKEN>" "<SID>" - Check exit code:
- If non-zero → tell user "视频生成过程中出了点问题,请稍后重试或检查你的 API token。" Stop. - If zero → capture stdout. This agentMsg is a post-rendering summary from CrePal. Do NOT re-enter the Decision Tree. Do NOT call confirm_generate again. Do NOT reply via message/send. Simply proceed to Step 4.
Step 4 — Compose & Download 🎬
After all video segments are rendered, you must compose the final video and get the download URL.
POST /api/openclaw/download/startwith:{"sessionId": "...", "watermark": false, "resolution": 1080}
- watermark: false by default (no watermark). Set true if user explicitly requests one. - resolution: 1080 by default. Use 720 only if user requests lower quality. - If the API call fails (HTTP error / no downloadId in response) → tell user "发起视频合成时遇到了问题,请稍后重试。" Stop. - Returns downloadId and estimated duration (seconds).
- Tell the user: "视频片段已全部完成,正在合成最终成片…"
- Run
poll_download.pyin FOREGROUND to wait for composing to finish:python3 scripts/poll_download.py "https://crepal.ai" "<TOKEN>" "<DOWNLOAD_ID>" - Check exit code:
- Non-zero → tell user "合成视频时遇到了问题,请稍后重试。" Stop. - Zero → capture stdout, which contains only the resultUrl (the download link).
- Present the download link to the user in a friendly message:
- "你的视频已经做好了!🎉 点击下载:"
Manual Mode
Active when auto_pilot is false. You pause at each step for user input.
- Call the relevant API endpoint (create session / send message / confirm generate).
- Save
sessionIdtometadata.json. - Run
poll_session.pyin FOREGROUND (no flags). Capture theagentMsgfrom stdout. - Present the
agentMsgcontent to the user in friendly language (never raw). Wait for their input. - Optionally also pass
--notify "<CHANNEL>"if you want the user to get a push notification.
Confirming generation in manual mode:
- User says "looks good" / "continue" about a script → use
message/send. - User says "start generating the video" → use
confirm_generate.
Composing the final video (after rendering is done):
- Call
POST /api/openclaw/download/startwithsessionId,watermark,resolution. - Run
poll_download.pyin FOREGROUND. CaptureresultUrlfrom stdout. - Present the download link to the user.
Recharge Workflow
Triggered when agentMsg or any API response mentions insufficient credits.
- Exit auto-pilot (if active).
POST /api/openclaw/subscription/config— get subscription plans.- Present plans with
stripeLinkto the user. - Optionally
POST /api/openclaw/one_time_products/config— get one-time credit packs. - After user recharges, resume via
message/send.
API Reference
Auth: Authorization: Bearer <api_key> on all requests. Base URL: https://crepal.ai
Create Session
POST /api/openclaw/chat/session/create
{ "content": "Help me generate a short video script" }Returns sessionId, messageId, status.
Send Message
POST /api/openclaw/chat/message/send
{ "sessionId": "...", "content": "Continue improving this video script" }Returns sessionId, messageId, status.
Check Session Ended
POST /api/openclaw/chat/session/check_end
{ "sessionId": "..." }Returns {"data": {"sessionId", "isEnded", "agentMsg"}}. Note: poll_session.py automates this — you rarely call it directly.
Confirm Script & Generate
POST /api/openclaw/script/confirm_generate
{ "sessionId": "..." }Starts video rendering. You must poll afterwards.
Start Download (Compose Final Video)
POST /api/openclaw/download/start
{ "sessionId": "...", "watermark": false, "resolution": 1080 }watermark(boolean): whether to add watermark. Defaultfalse.resolution(integer):720or1080. Default1080.- Returns
downloadId(string) andduration(estimated seconds).
Check Download Status
POST /api/openclaw/download/check
{ "downloadId": "..." }Returns {"data": {"status": "pending|success|failed", "resultUrl": "..."}}.
resultUrlis the download link whenstatusis"success".- Note:
poll_download.pyautomates this — you rarely call it directly.
Get Subscription Config
POST /api/openclaw/subscription/config No body. Returns subscriptions[] with planType, price, stripeLink, etc.
Get One-Time Products
POST /api/openclaw/one_time_products/config No body. Returns canPurchase, products[] with price, credits, stripeLink.
Resources
metadata.json
Persistent config. Read on startup, write whenever values change.
scripts/poll_session.py
Polls check_end every 5 s until isEnded is true.
Output behavior:
- No flags (foreground mode): prints only
agentMsgtext to stdout. All debug to stderr. This is the primary mode. --callback <ch>: stdout is completely silent. Sends[CREPAL_CALLBACK]message via openclaw CLI. (Fallback mode.)--notify <ch>: sends a short user-facing notification via openclaw CLI.--openclaw-path <path>: override auto-discovery of openclaw executable.
<ch> = user_channel from metadata.json.
# Primary: foreground, agent captures stdout (use this in auto-pilot)
python3 scripts/poll_session.py "https://crepal.ai" "<TOKEN>" "<SID>"
# With user notification (final step or manual mode)
python3 scripts/poll_session.py "https://crepal.ai" "<TOKEN>" "<SID>" --notify "<CHANNEL>"scripts/poll_download.py
Polls download/check every 5 s until status is success or failed.
Output: prints only the resultUrl to stdout when done. All debug to stderr.
python3 scripts/poll_download.py "https://crepal.ai" "<TOKEN>" "<DOWNLOAD_ID>"