Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help


教程:构建每日简报机器人

在本教程中,您将打造一个个性化的简报机器人,它每天清晨自动启动,为您查询感兴趣的主题、总结相关内容,并将简洁的简报直接发送到您的 Telegram 或 Discord 账户。

完成之后,您将拥有一个完全自动化的工作流,整合了网络搜索cron 定时任务任务委托以及消息推送功能——且无需编写任何代码。

::提示 该方案涵盖了网络搜索、内容总结以及可选的语音合成功能,所有这些功能都包含在 Portal 订阅服务中。最快的设置方式是执行 hermes setup --portal。详情请参阅 Nous Portal

::

我们要构建什么

具体流程如下:

  1. 上午 8:00 — cron 定时任务触发相应操作
  2. Hermes 根据您的提示启动一个新的智能体会话
  3. 网络搜索获取您关注主题的最新新闻
  4. 内容总结将信息整理成结构清晰的简报格式
  5. 消息推送将简报发送到您的 Telegram 或 Discord

整个流程无需人工干预,您只需边喝晨咖啡边阅读简报即可。

前提条件

在开始之前,请确保您已具备以下条件:

  • 已安装 Hermes Agent — 请参阅安装指南
  • 网关正在运行 — 网关守护进程负责处理 cron 定时任务的执行:
    hermes gateway install   # Install as a user service
    sudo hermes gateway install --system   # Linux servers: boot-time system service
    # or
    hermes gateway           # Run in foreground
    
  • Firecrawl API密钥 — 为网页搜索在环境变量中设置 FIRECRAWL_API_KEY
  • 消息传递功能已配置(非必需但推荐)—— 设置 Telegram 或 Discord,并创建一个主频道
:::提示 没有消息传递功能?没关系
您仍然可以通过使用 deliver: "local" 来完成本教程。任务说明将会保存在 ~/.hermes/cron/output/ 目录中,您可以随时查看。
::

第1步:手动测试工作流程

在实现自动化之前,我们先确认任务说明功能是否正常。首先启动一个聊天会话:

hermes

接着输入以下提示语:

Search for the latest news about AI agents and open source LLMs.
Summarize the top 3 stories in a concise briefing format with links.

Hermes会浏览网页、筛选相关结果,随后生成类似如下的内容:

☀️ Your AI Briefing — March 8, 2026

1. Qwen 3 Released with 235B Parameters
   Alibaba's latest open-weight model matches GPT-4.5 on several
   benchmarks while remaining fully open source.
   → https://qwenlm.github.io/blog/qwen3/

2. LangChain Launches Agent Protocol Standard
   A new open standard for agent-to-agent communication gains
   adoption from 15 major frameworks in its first week.
   → https://blog.langchain.dev/agent-protocol/

3. EU AI Act Enforcement Begins for General-Purpose Models
   The first compliance deadlines hit, with open source models
   receiving exemptions under the 10M parameter threshold.
   → https://artificialintelligenceact.eu/updates/

---
3 stories • Sources searched: 8 • Generated by Hermes Agent
如果此方法可行,那就意味着你已经准备好将其自动化了。

::提示 不断优化格式 尝试不同的提示词,直到得到令你满意的输出结果。可以添加诸如“使用表情符号作为标题”或“每条总结控制在两句话以内”之类的指令。最终确定的格式将用于定时任务中。

::

第2步:创建定时任务

现在让我们安排它每天早晨自动运行。有两种实现方式。

在创建定时任务之前,请确保Hermes已全局配置了默认模型和提供者。如果希望某个特定任务使用不同的设置,可在创建该任务时明确指定对应的模型/提供者替代值。

方案A:通过自然语言(在聊天界面中操作)

只需向Hermes说明你的需求即可:

Every morning at 8am, search the web for the latest news about AI agents
and open source LLMs. Summarize the top 3 stories in a concise briefing
with links. Use a friendly, professional tone. Deliver to telegram.

Hermes 将通过统一的 cronjob 工具为您创建定时任务。

方案 B:CLI 斜杠命令

如需更多控制权限,可使用 /cron 命令:

/cron add "0 8 * * *" "Search the web for the latest news about AI agents and open source LLMs. Find at least 5 recent articles from the past 24 hours. Summarize the top 3 most important stories in a concise daily briefing format. For each story include: a clear headline, a 2-sentence summary, and the source URL. Use a friendly, professional tone. Format with emoji bullet points and end with a total story count."

核心原则:自包含的提示语

:::warning 重要概念 Cron作业是在全新的会话环境中运行的——它不会记住你之前的对话内容,也不了解你“之前设置过什么”。因此,你的提示语必须包含代理完成任务所需的一切信息
::

错误的提示语示例:

Do my usual morning briefing.

优质提示词:

Search the web for the latest news about AI agents and open source LLMs.
Find at least 5 recent articles from the past 24 hours. Summarize the
top 3 most important stories in a concise daily briefing format. For each
story include: a clear headline, a 2-sentence summary, and the source URL.
Use a friendly, professional tone. Format with emoji bullet points.

一个优秀的提示词会明确说明需要搜索的内容文章数量输出格式以及语调风格。这些信息能一次性为智能体提供所需的一切。

第3步:定制任务说明

在基础的任务说明能够正常使用后,您就可以发挥创意了。

多主题任务说明

在一份任务说明中涵盖多个主题:

/cron add "0 8 * * *" "Create a morning briefing covering three topics. For each topic, search the web for recent news from the past 24 hours and summarize the top 2 stories with links.

Topics:
1. AI and machine learning — focus on open source models and agent frameworks
2. Cryptocurrency — focus on Bitcoin, Ethereum, and regulatory news
3. Space exploration — focus on SpaceX, NASA, and commercial space

Format as a clean briefing with section headers and emoji. End with today's date and a motivational quote."

利用任务委托实现并行研究

为加快信息汇总速度,可指示 Hermes 将每个研究主题委托给相应的子智能体处理:

/cron add "0 8 * * *" "Create a morning briefing by delegating research to sub-agents. Delegate three parallel tasks:

1. Delegate: Search for the top 2 AI/ML news stories from the past 24 hours with links
2. Delegate: Search for the top 2 cryptocurrency news stories from the past 24 hours with links
3. Delegate: Search for the top 2 space exploration news stories from the past 24 hours with links

Collect all results and combine them into a single clean briefing with section headers, emoji formatting, and source links. Add today's date as a header."

每个子代理会独立且并行地进行搜索,随后主代理会将所有结果整合成一份完整的汇报内容。如需了解其具体运作机制,请参阅任务委托文档

仅工作日调度

无需在周末接收汇报?可使用针对周一至周五的cron表达式:

/cron add "0 8 * * 1-5" "Search for the latest AI and tech news..."

每日两次简报

获取晨间概览与晚间总结:

/cron add "0 8 * * *" "Morning briefing: search for AI news from the past 12 hours..."
/cron add "0 18 * * *" "Evening recap: search for AI news from the past 12 hours..."

利用记忆功能添加个人上下文

如果您已启用记忆功能,便可以存储那些会在不同会话之间持续保留的偏好设置。但请注意:定时任务是在全新的会话中运行的,因此不保留对话历史记忆。若要添加个人上下文,可直接将其嵌入提示词中:

/cron add "0 8 * * *" "You are creating a briefing for a senior ML engineer who cares about: PyTorch ecosystem, transformer architectures, open-weight models, and AI regulation in the EU. Skip stories about product launches or funding rounds unless they involve open source.

Search for the latest news on these topics. Summarize the top 3 stories with links. Be concise and technical — this reader doesn't need basic explanations."
:::提示 定制智能体角色设定 详细说明信息传递的受众,能有效提升相关性与准确性。请告知智能体您的身份、兴趣以及哪些内容可以跳过。
::

第4步:管理您的任务

列出所有已安排的任务

在聊天界面中:

/cron list

或者通过终端操作:

hermes cron list

您将看到如下输出:

ID          | Name              | Schedule    | Next Run           | Deliver
------------|-------------------|-------------|--------------------|--------
a1b2c3d4    | Morning Briefing  | 0 8 * * *   | 2026-03-09 08:00   | telegram
e5f6g7h8    | Evening Recap     | 0 18 * * *  | 2026-03-08 18:00   | telegram

删除任务

在聊天界面中:

/cron remove a1b2c3d4

或者以对话方式询问:

Remove my morning briefing cron job.

Hermes会使用cronjob(action="list")来查找该任务,再通过cronjob(action="remove")将其删除。

检查网关状态

请确认调度器确实在运行中:

hermes cron status

如果网关未运行,您的任务将无法执行。为确保稳定性,请将其作为后台服务进行安装:

hermes gateway install
# or on Linux servers
sudo hermes gateway install --system

深入探索

您已经成功构建了一个可用的每日简报机器人。以下是接下来可以尝试的方向:

:::tip 还有哪些内容可以设置定时任务? 这种简报机器人模式几乎适用于所有场景:竞争对手监控、GitHub 代码库概要、天气预报、项目组合追踪、服务器健康检查,甚至每日趣闻。只要能用提示词描述出来,就可以安排其定时执行。
::