Skip to main content
Glama

generate_trigger_code

Generate Google Apps Script code to create automated triggers for time-based events, document actions, or form submissions, enabling scheduled or event-driven automation.

Instructions

Generate Apps Script code for creating triggers.

The Apps Script API cannot create triggers directly - they must be created from within Apps Script itself. This tool generates the code you need.

Args: trigger_type: Type of trigger. One of: - "time_minutes" (run every N minutes: 1, 5, 10, 15, 30) - "time_hours" (run every N hours: 1, 2, 4, 6, 8, 12) - "time_daily" (run daily at a specific hour: 0-23) - "time_weekly" (run weekly on a specific day) - "on_open" (simple trigger - runs when document opens) - "on_edit" (simple trigger - runs when user edits) - "on_form_submit" (runs when form is submitted) - "on_change" (runs when content changes)

function_name: The function to run when trigger fires (e.g., "sendDailyReport") schedule: Schedule details (depends on trigger_type): - For time_minutes: "1", "5", "10", "15", or "30" - For time_hours: "1", "2", "4", "6", "8", or "12" - For time_daily: hour as "0"-"23" (e.g., "9" for 9am) - For time_weekly: "MONDAY", "TUESDAY", etc. - For simple triggers (on_open, on_edit): not needed

Returns: Apps Script code to create the trigger. User should add this to their script and run the setup function once to install the trigger.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
trigger_typeYes
function_nameYes
scheduleNo

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sam-ent/appscript-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server