@iqai/plugin-heartbeat
v0.3.1
Published
A **plugin** for scheduling automated messages and social media posts using cron-based timing.
Readme
💓 Plugin Heartbeat
A plugin for scheduling automated messages and social media posts using cron-based timing.
📌 Overview
The Plugin Heartbeat provides a service for scheduling automated tasks that can:
✅ Schedule periodic messages ⏰
✅ Post to social media platforms 📱
✅ Maintain continuous agent interactions 🔄
✅ Support multiple concurrent schedules 📅
🛠 Installation
Install the plugin using pnpm:
pnpm add @iqai/plugin-heartbeat⚙ Configuration
The plugin requires configuration for clients. currently heartbeat plugin only supports twitter, telegram and callback.
| 🔧 Platform | 📜 Configuration Needed | |------------|------------------------| | Twitter | N/A | | Telegram | {chatId: string} | | Callback | {callback: (message: string) => Promise} |
Use callback to handle the message with your own logic.
🚀 Usage
Import and initialize the plugin:
import { createHeartbeatPlugin } from "@iqai/plugin-heartbeat";
// Initialize the plugin with tasks
const plugin = await createHeartbeatPlugin([
{
period: "*/30 * * * * *", // Cron schedule
input: "Your message prompt",
client: "telegram", // Social platform
config: {
chatId: "your-chat-id" // Platform-specific config
}
}
]);🎯 Task Configuration
Each heartbeat task requires:
✔ period: Cron expression for scheduling
✔ input: Message prompt for the agent
✔ client: Target platform ("telegram", "twitter", "webhook")
✔ config: Platform-specific configuration
💬 Example Tasks
[
{
"period": "*/30 * * * * *", // Every 30 seconds
"input": "Post a crypto joke",
"client": "telegram",
"config": { "chatId": "-1234567890" }
},
{
"period": "0 */1 * * *", // Every hour
"input": "Market update post",
"client": "twitter"
}
]📜 Response Handling
The plugin handles responses by:
✔ Processing agent responses 🤖
✔ Posting to specified platforms 📤
✔ Maintaining message history 📝
✔ Storing interactions in memory 💾
❌ Error Handling
The plugin manages various scenarios:
🚨 Missing client configurations
🌐 Network connection issues
📡 Platform API failures
⏰ Schedule execution errors
