Request
Register a trigger that will automatically invoke a function when certain conditions are met.
Response
The framework responds with a TriggerRegistrationResult message.
Message type. Will be "triggerregistrationresult".
The trigger ID from the request.
The trigger type from the request.
The function ID from the request.
Error details if registration failed. Omitted if successful.
Machine-readable error code (e.g., "trigger_type_not_found", "invalid_config", "function_not_found").
Human-readable error message describing what went wrong.
Examples
HTTP Trigger Registration
Request:
{
"type": "registertrigger",
"id": "http_webhook_handler",
"trigger_type": "http",
"function_id": "process_webhook",
"config": {
"path": "/webhooks/github",
"method": "POST"
}
}
Success Response:
{
"type": "triggerregistrationresult",
"id": "http_webhook_handler",
"trigger_type": "http",
"function_id": "process_webhook"
}
Cron Trigger Registration
Request:
{
"type": "registertrigger",
"id": "daily_report",
"trigger_type": "cron",
"function_id": "generate_report",
"config": {
"schedule": "0 9 * * *",
"timezone": "America/New_York"
}
}
Success Response:
{
"type": "triggerregistrationresult",
"id": "daily_report",
"trigger_type": "cron",
"function_id": "generate_report"
}
Queue Trigger Registration
Request:
{
"type": "registertrigger",
"id": "email_queue_processor",
"trigger_type": "queue",
"function_id": "send_email",
"config": {
"queue_name": "email_queue",
"batch_size": 10,
"visibility_timeout": 30
}
}
Success Response:
{
"type": "triggerregistrationresult",
"id": "email_queue_processor",
"trigger_type": "queue",
"function_id": "send_email"
}
Error Cases
Trigger Type Not Found
Request:
{
"type": "registertrigger",
"id": "my_trigger",
"trigger_type": "nonexistent_type",
"function_id": "my_function",
"config": {}
}
Error Response:
{
"type": "triggerregistrationresult",
"id": "my_trigger",
"trigger_type": "nonexistent_type",
"function_id": "my_function",
"error": {
"code": "trigger_type_not_found",
"message": "No trigger type registered with ID 'nonexistent_type'"
}
}
Function Not Found
Request:
{
"type": "registertrigger",
"id": "my_trigger",
"trigger_type": "http",
"function_id": "nonexistent_function",
"config": {
"path": "/test"
}
}
Error Response:
{
"type": "triggerregistrationresult",
"id": "my_trigger",
"trigger_type": "http",
"function_id": "nonexistent_function",
"error": {
"code": "function_not_found",
"message": "No function registered with ID 'nonexistent_function'"
}
}
Invalid Configuration
Request:
{
"type": "registertrigger",
"id": "cron_trigger",
"trigger_type": "cron",
"function_id": "my_function",
"config": {
"schedule": "invalid cron expression"
}
}
Error Response:
{
"type": "triggerregistrationresult",
"id": "cron_trigger",
"trigger_type": "cron",
"function_id": "my_function",
"error": {
"code": "invalid_config",
"message": "Invalid cron expression: 'invalid cron expression'"
}
}
Duplicate Trigger ID
Error Response:
{
"type": "triggerregistrationresult",
"id": "existing_trigger",
"trigger_type": "http",
"function_id": "my_function",
"error": {
"code": "duplicate_trigger_id",
"message": "A trigger with ID 'existing_trigger' is already registered"
}
}
Notes
- Trigger IDs must be unique within a worker session
- The function must be registered before registering a trigger for it
- The trigger type must be registered (via
RegisterTriggerType) before use
- Configuration structure is specific to each trigger type
- Successful registration returns a result without an
error field
- Failed registration returns a result with an
error field and no exception is thrown