Actions
Actions are Python scripts that your agents execute to automate tasks. They're the actual code that runs to accomplish goals like generating weekly sales reports, analyzing customer feedback, or monitoring website metrics.
What are Actions?
An action is a Python script that runs in a secure sandboxed environment. Each action belongs to an agent, runs on a schedule or manually, can be triggered via webhook, and produces documents and logs.
Creating Actions with Chat
The easiest way to create actions is through UpdateMate's chat interface. Describe what you want, and UpdateMate generates the Python code for you.
Navigate to an agent, click "New Action", and describe what the action should do. For example: "Generate a weekly sales report from HubSpot" or "Monitor Intercom conversations for negative sentiment". UpdateMate automatically creates Python code based on your description.
You can modify actions anytime using chat. Ask questions like "What does this code do?" or request changes like "Add error handling" or "Change the report format". Keep chatting until the action does exactly what you need.
Action Code Structure
All actions must have a run(app) function as the entry point. The app object provides everything your action needs to work.
def run(app):
app.log(step="Fetching data")
app.log("Connecting to API...")
# Your code here
The app Object
The app object provides access to:
app.secrets: Access workspace secrets (API keys, tokens, etc.). Use app.secrets.HUBSPOT_API_KEY to access secrets. They're never exposed in logs or documents.
app.log(): Record progress. Use app.log("...") for general messages, app.log(step="...") for major milestones, and app.log(error="...") for errors.
app.doc(): Create documents from markdown content. Documents support full markdown formatting and can include charts.
app.web: Make HTTP requests using the Requests library. Always use timeouts (15 minutes for APIs, 1 minute for other sites) and call raise_for_status() after requests.
app.llm(): Query AI models for analysis. Use app.llm("...") for text, json=True for JSON responses, and search=True for web search.
app.time: Work with dates and times. Use app.time.now() for current time, app.time.parse() to parse dates, and app.time.timedelta() for time differences.
app.args: Access arguments passed to webhook-triggered actions.
app.re and app.math: Standard Python libraries for regular expressions and math operations.
Action Schedules
Actions can run automatically on schedules or be triggered manually. Schedules use a cron-like format with fields: month, day_of_month, day_of_week, hour, minute. Examples: Daily at 9 AM (hour=9, minute=0), every Monday at 8 AM (day_of_week=1, hour=8, minute=0), every hour (minute=0).
Actions can also be triggered via webhook for real-time execution. When triggered via webhook, arguments are available through app.args.
Action States
Actions can be in one of two states: active (runs according to schedule or when triggered) or paused (temporarily disabled). New actions start in paused state.
What Happens When an Action Runs
When an action executes, it creates a log, runs your Python script step by step, records progress in real-time, creates documents, and completes or reports errors. You can watch actions run in real-time by viewing their logs.
Understanding Action Logs
Every time an action runs, it creates a log entry showing execution status (running, done, error, or stopped), progress steps, detailed messages, timing, errors, and links to documents created. Logs update in real-time as actions execute.
Action Outputs
Actions produce two main types of outputs: documents (reports, summaries, analyses created using app.doc()) and logs (detailed records of execution).
Best Practices
Keep actions focused on one specific task. Use descriptive names. Test before scheduling by running manually first. Use chat to iterate and refine. Monitor regularly by checking logs and documents. Log clearly using app.log() to make progress easy to follow.
Next Steps
Now that you understand actions, create your first action using chat, review action logs, check documents, set up schedules, and configure webhooks for real-time triggers.
Actions are the building blocks of automation in UpdateMate. Once configured, they work tirelessly in the background to keep you informed and productive.