Create Instagram Carousel Post
End-to-end pipeline: itinerary URL → photo sourcing → text overlays → Instagram carousel publish.
Parameters
- - itinerary_url (required): tabiji.ai itinerary URL (e.g.
https://tabiji.ai/i/thaw-dome/) - destination (required): City/region name (e.g. "Kuala Lumpur")
- attractions (required): List of 5 attraction names + short descriptions
- caption (optional): Custom caption. If omitted, generate one with destination name, attraction list, CTA to link in bio, and relevant hashtags.
Pipeline (3 chained sub-agents recommended)
Split into 3 sub-agents for reliability. Each writes outputs to /tmp/ig-carousel/.
Sub-agent 1: Photo Finding
Use the instagram-photo-find skill workflow for each subject (1 destination + 5 attractions = 6 total).
For each subject:
- 1.
web_search: site:instagram.com/p/ "{subject}" photo (10 results) - Download top 5 candidates: INLINECODE5
- Vision-score each with: "Rate 1-10 as hero destination photo for {subject}. Description + score only."
- Keep best per subject → INLINECODE6
Output: 6 best images + JSON manifest at /tmp/ig-carousel/manifest.json:
CODEBLOCK0
Sub-agent 2: Text Overlays
Read manifest from sub-agent 1. Run overlay script for each image.
Slide 1 (cover) — clean style:
CODEBLOCK1
Slides 2–6 — quote style per attraction with insider tip:
CODEBLOCK2
Output: 6 overlay images at INLINECODE8
Sub-agent 3: Publish to Instagram
- 1. Host images publicly — copy slides to tabiji repo (
img/instagram/), git push, use raw GitHub URLs (https://raw.githubusercontent.com/psyduckler/tabiji/main/img/instagram/slide-{N}.jpg). Wait ~30s after push for GitHub CDN.
- 2. Create carousel item containers (one per slide):
CODEBLOCK3
- 3. Create carousel container with all children + caption:
CODEBLOCK4
- 4. Publish:
CODEBLOCK5
- 5. Get permalink (or verify publish on rate-limit error):
If media_publish returns a POST_ID, get the permalink directly:
CODEBLOCK6
If media_publish returns error 2207051 (rate limit / action blocked): Instagram sometimes processes the request despite returning an error. Always verify by checking the account's recent media before declaring failure:
curl -s "https://graph.facebook.com/v21.0/${IG_USER}/media?fields=id,timestamp,permalink&limit=1&access_token=${IG_TOKEN}"
If the most recent post timestamp is within the last few minutes, the publish likely succeeded — grab that permalink.
- 6. Cleanup hosted images — after publish is confirmed, delete the images from the tabiji repo and push:
cd /path/to/tabiji/repo
git rm img/instagram/slide-*.jpg
git commit -m "cleanup: remove instagram carousel images after publish"
git push
Also clean up local temp files:
CODEBLOCK9
Output: Instagram post URL
Instagram API Auth
Keys from macOS Keychain:
- -
instagram-access-token — Graph API token - INLINECODE15 — IG user ID (17841449394591017)
Caption Template
CODEBLOCK10
Tips
- - Raw GitHub URLs work for IG image_url; tabiji.ai Cloudflare CDN may trigger format validation errors.
- Add
sleep 1 between container creation calls to avoid rate limits. - If a subject yields low photo scores (<5), broaden search: try Unsplash/Flickr or more specific landmark names.
- Islamic/cultural museums tend to have fewer quality IG photos — try searching the museum's official IG handle.
创建Instagram轮播帖子
端到端流程:行程URL → 照片获取 → 文字叠加 → Instagram轮播发布。
参数
- - itinerary_url(必填):tabiji.ai行程URL(例如 https://tabiji.ai/i/thaw-dome/)
- destination(必填):城市/地区名称(例如吉隆坡)
- attractions(必填):5个景点名称及简短描述的列表
- caption(可选):自定义文案。如果省略,将自动生成包含目的地名称、景点列表、个人简介链接引导和相关话题标签的文案。
流程(建议使用3个链式子代理)
为提高可靠性,拆分为3个子代理。每个子代理将输出写入 /tmp/ig-carousel/。
子代理1:照片查找
对每个主题(1个目的地 + 5个景点 = 共6个)使用 instagram-photo-find 技能工作流。
对每个主题:
- 1. web_search:site:instagram.com/p/ {subject} photo(10个结果)
- 下载前5个候选图片:curl -s -L -o /tmp/ig-carousel/raw-{slug}-{n}.jpg https://www.instagram.com/p/{shortcode}/media/?size=l
- 使用视觉评分:以1-10分评价作为{subject}的目的地主图照片。仅返回描述和评分。
- 每个主题保留最佳图片 → /tmp/ig-carousel/{slug}-best.jpg
输出:6张最佳图片 + JSON清单文件 /tmp/ig-carousel/manifest.json:
json
[{slug: kuala-lumpur, subject: Kuala Lumpur, score: 7, path: /tmp/ig-carousel/kuala-lumpur-best.jpg, source: instagram.com/p/XXX/}]
子代理2:文字叠加
读取子代理1的清单文件。对每张图片运行叠加脚本。
幻灯片1(封面) — 简洁风格:
bash
python3 skills/instagram-photo-text-overlay/scripts/overlay.py \
--input /tmp/ig-carousel/{dest-slug}-best.jpg \
--output /tmp/ig-carousel/slide-1.jpg \
--title {N}天{DESTINATION}行程亮点 \
--style clean --watermark tabiji.ai
幻灯片2–6 — 每个景点引用风格,附内行贴士:
bash
python3 skills/instagram-photo-text-overlay/scripts/overlay.py \
--input /tmp/ig-carousel/{slug}-best.jpg \
--output /tmp/ig-carousel/slide-{N}.jpg \
--title {ATTRACTION} \
--quote {关于该景点的具体内行贴士——必须直接引用标题中的地点,而非通用旅行建议} \
--author tabiji.ai \
--style quote --watermark tabiji.ai
输出:6张叠加图片,位于 /tmp/ig-carousel/slide-{1-6}.jpg
子代理3:发布到Instagram
- 1. 公开托管图片 — 将幻灯片复制到tabiji仓库(img/instagram/),git推送,使用GitHub原始URL(https://raw.githubusercontent.com/psyduckler/tabiji/main/img/instagram/slide-{N}.jpg)。推送后等待约30秒让GitHub CDN生效。
- 2. 创建轮播项目容器(每张幻灯片一个):
bash
curl -s -X POST https://graph.facebook.com/v21.0/${IG_USER}/media \
-d image
url=${PUBLICURL} \
-d is
carouselitem=true \
-d access
token=${IGTOKEN}
- 3. 创建轮播容器,包含所有子项和文案:
bash
curl -s -X POST https://graph.facebook.com/v21.0/${IG_USER}/media \
--data-urlencode caption=${CAPTION} \
-d media_type=CAROUSEL \
-d children=${CHILD_IDS} \
-d access
token=${IGTOKEN}
- 4. 发布:
bash
curl -s -X POST https://graph.facebook.com/v21.0/${IG
USER}/mediapublish \
-d creation
id=${CAROUSELID} \
-d access
token=${IGTOKEN}
- 5. 获取永久链接(或在遇到速率限制错误时验证发布):
如果 mediapublish 返回 POSTID,直接获取永久链接:
bash
curl -s https://graph.facebook.com/v21.0/${POSTID}?fields=permalink&accesstoken=${IG_TOKEN}
如果 media_publish 返回错误2207051(速率限制/操作被阻止): Instagram有时会在返回错误的情况下仍处理请求。在宣布失败前,务必通过检查账户的最近媒体来验证:
bash
curl -s https://graph.facebook.com/v21.0/${IGUSER}/media?fields=id,timestamp,permalink&limit=1&accesstoken=${IG_TOKEN}
如果最近发布的时间戳在几分钟内,则发布很可能已成功——获取该永久链接。
- 6. 清理托管的图片 — 确认发布后,从tabiji仓库删除图片并推送:
bash
cd /path/to/tabiji/repo
git rm img/instagram/slide-*.jpg
git commit -m cleanup: remove instagram carousel images after publish
git push
同时清理本地临时文件:
bash
rm -rf /tmp/ig-carousel/
输出:Instagram帖子URL
Instagram API认证
从macOS钥匙串获取密钥:
- - instagram-access-token — Graph API令牌
- instagram-account-id — IG用户ID(17841449394591017)
文案模板
🇲🇾 {N}晚{Destination}之旅 — {行程副标题}
{关于这次旅行的一句话引子}
📍 滑动查看我们的前5推荐:
- 1. {景点1} — {一句话理由}
- {景点2} — {一句话理由}
- {景点3} — {一句话理由}
- {景点4} — {一句话理由}
- {景点5} — {一句话理由}
包含贴士、价格和Reddit推荐的完整免费行程 👉 {ITINERARY_URL}
💬 {引发思考的问题 — 例如{Destination}住5晚够吗,还是需要更多?或大多数游客对{Destination}最大的误解是什么?}
#{destination_hashtag} #{country} #travelitinerary #foodietravel #southeastasia #asiatravel #travelguide #tabiji
提示
- - GitHub原始URL适用于IG的image_url;tabiji.ai的Cloudflare CDN可能触发格式验证错误。
- 在容器创建调用之间添加 sleep 1 以避免速率限制。
- 如果某个主题的照片评分较低(<5),扩大搜索范围:尝试Unsplash/Flickr或更具体的地标名称。
- 伊斯兰/文化博物馆的优质IG照片通常较少——尝试搜索博物馆的官方IG账号。