#207 Apps: Create complex demo app (Notification Hub)

closed high Created 2025-12-01 04:16 · Updated 2025-12-01 05:15

Description

Edit
## Parent Epic: #195 ## Description Create a complex app demonstrating all SDK capabilities. ## Location engine/apps/examples/notification_hub.py ## Notification Hub App Multi-channel notification app showing: - HTTP requests with checkpoints - Configuration usage - Secrets management - Event emission - Event waiting - State management - Logging ## Actions ### send_notification ```python @action( description='Send notification to configured channels', parameters={ 'type': 'object', 'properties': { 'title': {'type': 'string'}, 'message': {'type': 'string'}, 'channels': {'type': 'array', 'items': {'type': 'string'}}, 'priority': {'type': 'string', 'enum': ['low', 'normal', 'high']}, }, 'required': ['title', 'message'] } ) def send_notification(self, ctx: AppContext, title: str, message: str, channels: list[str] | None = None, priority: str = 'normal') -> dict: # Get default channels from config default_channels = ctx.get_config('default_channels', ['email']) channels = channels or default_channels results = {} for channel in channels: result = ctx.checkpoint( f'send_{channel}', self._send_to_channel, ctx, channel, title, message, priority ) results[channel] = result # Emit event for tracking ctx.emit_event('notification_sent', { 'title': title, 'channels': channels, 'results': results, }) return {'success': True, 'results': results} ``` ### wait_for_acknowledgement ```python @action( description='Wait for user to acknowledge notification', waits_for_event=True, ... ) def wait_for_acknowledgement(self, ctx: AppContext, notification_id: str, timeout_seconds: int = 3600) -> dict: ack_event = ctx.wait_for_event( 'wait_ack', f'ack_{notification_id}', timeout_seconds, ) return { 'acknowledged': True, 'user': ack_event.get('user'), 'timestamp': ack_event.get('timestamp'), } ``` ### schedule_notification ```python @action(description='Schedule notification for later') def schedule_notification(self, ctx: AppContext, delay_seconds: int, **notification_kwargs) -> dict: ctx.sleep('wait_delay', delay_seconds) return self.send_notification(ctx, **notification_kwargs) ``` ## Required Secrets - email_api_key - slack_webhook_url - sms_api_key ## Configuration Schema ```json { 'type': 'object', 'properties': { 'default_channels': {'type': 'array'}, 'email_from': {'type': 'string'}, 'retry_attempts': {'type': 'integer', 'default': 3} } } ``` ## Testing - All actions unit tested - Integration test with mock HTTP - Event emission/waiting test - Configuration/secrets test

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...