Send Custom Event
Send Custom Event Mutation
Sends a custom event to the pyck event system for processing by workflows and external integrations.
Arguments
input
SendCustomEventInput!
Input data for the custom event
Return Type
SendCustomEventResponse - Confirmation of the event submission.
Input Fields
SendCustomEventInput:
type
String!
The type/category of the event
operation
String!
The operation being performed
payload
Map!
Event data and context information
Return Fields
SendCustomEventResponse:
success
Boolean!
Whether the event was successfully submitted
Usage Example
Event Types and Operations
Common Event Types
Inventory Events
Type:
"inventory"Operations:
"low_stock_alert"- Stock levels below threshold"reorder_point_reached"- Time to reorder inventory"excess_stock_detected"- Overstock situation"item_expired"- Perishable items approaching expiration
Customer Events
Type:
"customer"Operations:
"milestone_reached"- Customer loyalty milestones"payment_overdue"- Late payment notifications"preference_updated"- Customer preference changes"complaint_received"- Customer service issues
Order Events
Type:
"order"Operations:
"rush_order_received"- Expedited order processing"bulk_order_discount"- Large order special handling"order_modification"- Changes to existing orders"delivery_delay"- Shipping delays and notifications
Quality Events
Type:
"quality"Operations:
"inspection_failed"- Quality control failures"compliance_violation"- Regulatory compliance issues"supplier_rating_changed"- Supplier performance updates"recall_initiated"- Product recall procedures
Workflow Events
Type:
"workflow"Operations:
"manual_approval_required"- Human intervention needed"process_exception"- Workflow exception handling"sla_breach"- Service level agreement violations"escalation_triggered"- Process escalation events
JavaScript Example
Event Processing
Workflow Integration
Custom events can trigger Temporal workflows:
Inventory Management: Automatic reordering workflows
Customer Service: Support ticket creation and routing
Quality Control: Inspection and compliance workflows
Notification Systems: Email, SMS, and push notifications
External System Integration
Events can be consumed by external systems:
ERP Systems: Business process automation
CRM Platforms: Customer relationship management
Analytics Tools: Business intelligence and reporting
Monitoring Systems: Alerting and dashboard updates
Event Routing
Events are routed based on:
Event Type: Different handlers for different event categories
Operation: Specific processing logic for each operation
Payload Content: Conditional routing based on event data
Tenant Configuration: Organization-specific event handling
Payload Guidelines
Required Fields
While the payload is flexible, consider including:
Entity IDs: Reference to related entities (customer, item, order, etc.)
Timestamp: When the event occurred
Source: System or user that generated the event
Priority/Urgency: Event importance level
Context: Additional information for processing
Data Types
The payload Map supports:
Strings: Text data and identifiers
Numbers: Quantities, amounts, measurements
Booleans: Flags and status indicators
Objects: Nested data structures
Arrays: Lists of related items
Best Practices
Consistent Naming: Use consistent field names across similar events
Complete Context: Include all necessary information for processing
Avoid Sensitive Data: Don't include passwords or API keys
Structured Data: Use nested objects for complex information
Documentation: Document payload structure for each event type
Error Handling
Events may fail to process due to:
Invalid Type/Operation: Unknown event type or operation
Malformed Payload: Invalid or missing required data
System Overload: Event queue at capacity
Permission Issues: Insufficient rights to send certain events
Configuration Problems: Event routing or processing configuration errors
Monitoring and Observability
Event Tracking
Monitor custom events through:
Event Logs: Detailed logs of all event processing
Metrics Dashboards: Event volume and processing times
Error Rates: Failed event processing statistics
Workflow Triggers: Events that successfully triggered workflows
Performance Considerations
Event Volume: Monitor event throughput and system capacity
Processing Latency: Time from event submission to processing
Queue Depth: Backlog of pending events
Resource Usage: CPU and memory consumption during event processing
Notes
Events are processed asynchronously - success indicates submission, not completion
Event types and operations should be coordinated across teams
Consider implementing event versioning for backwards compatibility
Use meaningful, descriptive event types and operations
Test event processing in development environments before production use
Last updated
Was this helpful?
