Show / hide languages:
📋 Course plans · Week 6 / 6

📱 Week 6 — Social + Capstone

Buffer + Slack tools — schedule, never publish. Then a single Hermes prompt that chains all five connectors.

เครื่องมือ Buffer + Slack — จัดคิวเท่านั้น ไม่ publish จากนั้นใช้ prompt เดียวของ Hermes เชื่อม 5 connector ทั้งหมด

Buffer + Slack 工具 — 只排程,绝不直接发布。然后用一条 Hermes 提示串起全部五个连接器。

📅 Buffer 💬 Slack webhook 🏁 End-to-end capstone ⏱️ 90 min

🎯 Learning objectives

1

Schedule, never post

The only new social tool is buffer_schedule — no post_now exists.

เครื่องมือใหม่ทาง social มีแค่ buffer_schedule ไม่มี post_now

本周唯一新加的社交工具是 buffer_schedule,没有 post_now。

2

Sentiment monitor loop

A 15-min loop that pings Slack on negative mentions — runs via launchd.

Loop 15 นาทีที่ ping Slack เวลามี mention เชิงลบ รันด้วย launchd

每 15 分钟轮询的回路;遇到负面提及就推送到 Slack — 同样由 launchd 触发。

3

Capstone integration

One agent.chat() call. Five systems. No cloud LLM.

เรียก agent.chat() ครั้งเดียว ครบ 5 ระบบ ไม่ใช้ cloud LLM

一次 agent.chat(),覆盖五个系统,不用云端 LLM。

🏁 Interactive: trace the capstone flow

An Instagram DM arrives. Click each step to see what Hermes calls — and which tool from which week handles it.

DM Instagram เข้ามา คลิกแต่ละขั้นดูว่า Hermes เรียกอะไร และเครื่องมือสัปดาห์ไหนรับช่วงต่อ

Instagram 私信进来。点击每一步看 Hermes 调了什么、由第几周的工具处理。

📱
1. Inbound DM
Instagram → text
🎧
2. Support RAG
query_policy() · W5
🤝
3. CRM upsert
upsert_hubspot() · W4
📅
4. Calendar
list_free_slots() · W3
📧
5. Email draft
draft_gmail_reply() · W2
📣
6. Social schedule
buffer_schedule() · W6
Click any step above for details.

📚 Key concepts

🇬🇧 English

Rate limits — Buffer/X/Slack each cap RPM. The FunctionTool catches 429s and backs off; it does not retry instantly.

Schedule-only surface — the agent's only social action is queuing in Buffer. post_now() as a tool does not exist.

Sentiment loop — a separate mentions_brief.py script with its own launchd entry, reusing the same build_agent().

🇹🇭 ไทย

Rate limits — Buffer/X/Slack จำกัด RPM FunctionTool จับ 429 แล้ว back off ไม่รีทรายทันที

schedule-only — action บน social มีแค่ queue ใน Buffer ไม่มี post_now()

Sentiment loop — mentions_brief.py แยก ใช้ build_agent() เดิม

🇨🇳 中文

速率限制 — Buffer/X/Slack 都有 RPM 上限。FunctionTool 捕获 429 后退避,绝不立即重试。

只许排程 — 代理唯一的社交动作是把内容塞进 Buffer 队列。post_now() 工具不存在。

情感回路 — 单独的 mentions_brief.py 复用同一个 build_agent()。

🧪 Hands-on lab

1
2
3
4
1

Buffer schedule tool

import requests, os BUF = "https://api.bufferapp.com/1" def buffer_schedule(text: str, profile_id: str, when_iso: str) -> str: """Queue a post in Buffer for the given profile. NEVER publishes directly.""" r = requests.post(f"{BUF}/updates/create.json", params={"access_token": os.environ["BUFFER_TOKEN"]}, data={"profile_ids[]": profile_id, "text": text, "scheduled_at": when_iso}, timeout=10) return f"queued: {r.status_code} {r.text[:100]}" TOOLS.append(FunctionTool.from_defaults(buffer_schedule))
2

Slack alert tool

def post_slack_alert(message: str) -> str: """Post a one-line alert to #ai-mentions via incoming webhook.""" r = requests.post(os.environ["SLACK_WEBHOOK"], json={"text": message}, timeout=10) return f"slack: {r.status_code}" TOOLS.append(FunctionTool.from_defaults(post_slack_alert))
3

The sentiment monitor — also via launchd

# mentions_brief.py — launchd runs this every 15 min, reuses agent_pro.py from agent_pro import build_agent agent = build_agent() print(agent.chat( "Evaluate these brand mentions. For each, classify pos/neutral/neg/urgent. " "Call post_slack_alert ONLY for negative or urgent ones. " "Mentions:\n" + open("mentions.txt").read() ))
4

CAPSTONE — capstone.py

from agent_pro import build_agent agent = build_agent() # now has every FunctionTool from weeks 1–5 + Buffer + Slack print(agent.chat(""" An Instagram DM arrived: "Hi, do you have a 3-day jungle trek? My name is Marco, +393331234567." 1. Use query_policy to answer the difficulty question. 2. upsert_hubspot_contact (phone is the idempotency key). 3. list_free_slots for next Tuesday; pick one and convert to Marco's time. 4. draft_gmail_reply with a packing list (NEVER send). 5. buffer_schedule a Facebook post about jungle treks for Friday 18:00 ICT. 6. Report a one-paragraph summary of what you did. """))

⚠️ Capstone constraint

Must run against local Hermes only — ollama serve + hermes3:8b. No proprietary LLM keys allowed. This proves the whole pipeline works without cloud dependencies.

ต้องรันบน Hermes local เท่านั้น — ollama serve + hermes3:8b ห้ามใช้ key LLM เจ้าอื่น พิสูจน์ว่า pipeline ใช้งานได้โดยไม่ต้องพึ่ง cloud

必须只在本地 Hermes 上跑 — ollama serve + hermes3:8b。不允许任何商用 LLM 密钥。这样才能证明整条流水线不依赖云端。

🏆 Capstone rubric (10 pts)

4

Integration

Chain touches all 5 systems (Social, Support, CRM, Calendar, Email) without crashing.

เชื่อมครบ 5 ระบบ (Social, Support, CRM, Calendar, Email) โดยไม่ crash

链路覆盖 Social/Support/CRM/Calendar/Email 五系统而不崩溃。

3

Safety / HITL

Every external action lands in Drafts / Buffer-queue / Slack-alert. Nothing sent live.

action ภายนอกทุกอันลงที่ Drafts / Buffer queue / Slack alert ไม่ส่งจริง

所有外部动作都落在 Drafts/Buffer 队列/Slack 提醒,不直接发送。

3

Business logic

Idempotency in CRM upserts; policy-grounded support answer; conflict re-check before booking.

CRM upsert มี idempotency, ตอบ support อิง policy, เช็คเวลาทับซ้อนก่อนจอง

CRM upsert 幂等;客服答案有政策依据;订单前再次冲突检查。

⚠️ Top gotchas

1. Runaway loops

A sentiment monitor hitting a network error retrying instantly will spam Slack and exhaust Buffer rate limits. Wrap with backoff + a daily cap.

Sentiment monitor เจอ network error แล้วรีทรายทันทีจะ spam Slack + เผา Buffer ห่อด้วย backoff + daily cap

情感监控遇到网络错误立即重试会刷爆 Slack 与 Buffer 限额。加退避和每日上限。

2. Context bloat

Feeding raw daily mentions JSON blows past Hermes' context. Pre-filter to ~20 mentions per run.

ป้อน JSON mention ทั้งวัน = context แตก กรองเหลือ ~20 mention ต่อรอบ

把整天提及的原始 JSON 喂进去会爆上下文。每次预过滤到约 20 条。

3. The "post-now" temptation

Never add a buffer_publish_now tool. Keep the agent's external action surface queue-only / read-only.

อย่าเพิ่ม buffer_publish_now เด็ดขาด ให้ surface เป็น queue-only / read-only

绝不要加 buffer_publish_now。代理的对外动作面只许排程、只许读取。

🌱 What to take forward

🇬🇧 After the course

  • Keep the guardrails. No send_email. No buffer_publish_now. Run draft-then-confirm for at least 3 months.
  • Iterate the prompts and the index, not the output. When Hermes errs, update the responder's system prompt or re-index a clearer policy doc.
  • Embrace the reviewer. Every new external action gets an adversarial Hermes checking it before the closer runs.

🇹🇭 หลังจบหลักสูตร

  • เก็บ guardrail ไว้ อย่าเพิ่ม send_email หรือ buffer_publish_now ใช้ draft-then-confirm อย่างน้อย 3 เดือน
  • แก้ที่ prompt และ index ไม่ใช่ที่ output Hermes ผิดที่ไหน อัปเดต system prompt หรือ re-index policy doc
  • มี reviewer เสมอ action ภายนอกใหม่ทุกอันต้องมี adversarial Hermes เช็คก่อน closer

🇨🇳 课程之后

  • 保留护栏。不要加 send_email,不要加 buffer_publish_now。至少坚持先草稿后确认 3 个月。
  • 修提示词和索引,而不是修产出。Hermes 出错时,更新回复者的系统提示,或重建一份更清晰的策略文档。
  • 始终留一个审查者。每加一个新的外部动作,先让一个对抗的 Hermes 把关。