Files
Memoh/assets/getting-started_schedule.md.BgiO7WiT.js
2026-04-23 13:02:42 +00:00

15 lines
10 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{_ as t,o as a,c as s,ag as n}from"./chunks/framework.CAXxHpAX.js";const p=JSON.parse('{"title":"Scheduled Tasks","description":"","frontmatter":{},"headers":[],"relativePath":"getting-started/schedule.md","filePath":"getting-started/schedule.md","lastUpdated":1774459922000}'),i={name:"getting-started/schedule.md"};function o(r,e,d,l,h,c){return a(),s("div",null,[...e[0]||(e[0]=[n(`<h1 id="scheduled-tasks" tabindex="-1">Scheduled Tasks <a class="header-anchor" href="#scheduled-tasks" aria-label="Permalink to &quot;Scheduled Tasks&quot;"></a></h1><p>Scheduled Tasks allow you to automate recurring bot actions using cron expressions. This is useful for sending periodic reports, checking external data, performing maintenance, or triggering any routine task without manual intervention.</p><h2 id="concept-cron-based-automation" tabindex="-1">Concept: Cron-Based Automation <a class="header-anchor" href="#concept-cron-based-automation" aria-label="Permalink to &quot;Concept: Cron-Based Automation&quot;"></a></h2><p>A <strong>Schedule</strong> is a cron-triggered rule bound to a specific bot. When a schedule fires, it sends a command to the agent, which executes it using its available tools, skills, and context. The bot can then deliver results to any connected channel.</p><hr><h2 id="schedule-fields" tabindex="-1">Schedule Fields <a class="header-anchor" href="#schedule-fields" aria-label="Permalink to &quot;Schedule Fields&quot;"></a></h2><table tabindex="0"><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>A display name for the task (e.g., &quot;Morning News Summary&quot;).</td></tr><tr><td><strong>Description</strong></td><td>A brief explanation of what the task does.</td></tr><tr><td><strong>Pattern</strong></td><td>A cron expression that defines when the task runs (e.g., <code>0 9 * * *</code> for daily at 9:00 AM).</td></tr><tr><td><strong>Command</strong></td><td>The natural-language instruction sent to the agent when the schedule triggers (e.g., &quot;Summarize today&#39;s top tech news and send it to the Telegram channel&quot;).</td></tr><tr><td><strong>Enabled</strong></td><td>Whether the schedule is currently active.</td></tr><tr><td><strong>Max Calls</strong></td><td>Optional limit on the total number of executions. Leave empty for unlimited.</td></tr><tr><td><strong>Current Calls</strong></td><td>The number of times this schedule has already fired.</td></tr></tbody></table><hr><h2 id="cron-pattern-reference" tabindex="-1">Cron Pattern Reference <a class="header-anchor" href="#cron-pattern-reference" aria-label="Permalink to &quot;Cron Pattern Reference&quot;"></a></h2><p>The <code>pattern</code> field uses standard cron syntax with five fields. It is evaluated in the server&#39;s configured timezone. By default, Memoh uses <code>UTC</code>, and you can change it with the top-level <code>timezone</code> config value.</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>┌───────────── minute (059)</span></span>
<span class="line"><span>│ ┌───────────── hour (023)</span></span>
<span class="line"><span>│ │ ┌───────────── day of month (131)</span></span>
<span class="line"><span>│ │ │ ┌───────────── month (112)</span></span>
<span class="line"><span>│ │ │ │ ┌───────────── day of week (06, Sun=0)</span></span>
<span class="line"><span>│ │ │ │ │</span></span>
<span class="line"><span>* * * * *</span></span></code></pre></div><p><strong>Common examples:</strong></p><table tabindex="0"><thead><tr><th>Pattern</th><th>Meaning</th></tr></thead><tbody><tr><td><code>0 9 * * *</code></td><td>Every day at 9:00 AM</td></tr><tr><td><code>*/30 * * * *</code></td><td>Every 30 minutes</td></tr><tr><td><code>0 0 * * 1</code></td><td>Every Monday at midnight</td></tr><tr><td><code>0 8,20 * * *</code></td><td>Every day at 8:00 AM and 8:00 PM</td></tr><tr><td><code>0 0 1 * *</code></td><td>First day of every month at midnight</td></tr></tbody></table><hr><h2 id="viewing-schedules" tabindex="-1">Viewing Schedules <a class="header-anchor" href="#viewing-schedules" aria-label="Permalink to &quot;Viewing Schedules&quot;"></a></h2><ol><li>Navigate to the Bot <strong>Detail Page</strong>.</li><li>Select the <strong>Schedule</strong> tab.</li><li>The list shows all schedules for this bot, including their name, cron pattern, enabled status, and execution counts.</li><li>Click <strong>Refresh</strong> to reload the list.</li></ol><hr><h2 id="creating-schedules" tabindex="-1">Creating Schedules <a class="header-anchor" href="#creating-schedules" aria-label="Permalink to &quot;Creating Schedules&quot;"></a></h2><p>Schedules are primarily created in two ways:</p><h3 id="via-the-bot-conversational" tabindex="-1">Via the Bot (Conversational) <a class="header-anchor" href="#via-the-bot-conversational" aria-label="Permalink to &quot;Via the Bot (Conversational)&quot;"></a></h3><p>The bot itself has access to a <code>schedule</code> tool. You can ask the bot to create a schedule in natural language:</p><blockquote><p>&quot;Create a schedule called &#39;Daily Digest&#39; that runs every day at 8 AM and sends me a summary of my unread emails.&quot;</p></blockquote><p>The bot will translate this into a cron expression and register the schedule automatically.</p><h3 id="via-the-api" tabindex="-1">Via the API <a class="header-anchor" href="#via-the-api" aria-label="Permalink to &quot;Via the API&quot;"></a></h3><p>You can also create schedules programmatically using the REST API:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>POST /api/bots/{bot_id}/schedule</span></span></code></pre></div><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;name&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Daily Digest&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;description&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Summarize unread emails every morning&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;pattern&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;0 8 * * *&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;command&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Summarize my unread emails and send the result to Telegram.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;enabled&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> &quot;max_calls&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">null</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><hr><h2 id="execution-flow" tabindex="-1">Execution Flow <a class="header-anchor" href="#execution-flow" aria-label="Permalink to &quot;Execution Flow&quot;"></a></h2><p>When a schedule fires:</p><ol><li>The cron service triggers the schedule.</li><li>The <code>current_calls</code> counter is incremented.</li><li>If <code>max_calls</code> is set and reached, the schedule is automatically disabled.</li><li>The agent receives the <code>command</code> along with the schedule context.</li><li>The agent executes the command using its tools (e.g., web search, file read, send message).</li><li>Results can be delivered to any connected channel.</li></ol><hr><h2 id="schedule-vs-heartbeat" tabindex="-1">Schedule vs. Heartbeat <a class="header-anchor" href="#schedule-vs-heartbeat" aria-label="Permalink to &quot;Schedule vs. Heartbeat&quot;"></a></h2><table tabindex="0"><thead><tr><th>Feature</th><th>Schedule</th><th>Heartbeat</th></tr></thead><tbody><tr><td><strong>Trigger</strong></td><td>Cron expression (flexible timing)</td><td>Fixed interval (minutes)</td></tr><tr><td><strong>Command</strong></td><td>Custom natural-language instruction</td><td>Generic &quot;routine check&quot; prompt</td></tr><tr><td><strong>Max Calls</strong></td><td>Optional execution limit</td><td>Unlimited</td></tr><tr><td><strong>Use Case</strong></td><td>Specific recurring tasks</td><td>Periodic autonomous thinking</td></tr></tbody></table><p>Both features complement each other: use <strong>Heartbeat</strong> for general-purpose periodic activity and <strong>Schedule</strong> for precise, task-oriented automation.</p>`,35)])])}const g=t(i,[["render",o]]);export{p as __pageData,g as default};