Initial commit: Motia III Backend Setup
- iii-config.yaml mit Production-Settings (CORS, all interfaces) - Ticketing-System Steps (create, triage, escalate, notify, SLA monitoring) - Python dependencies via uv - Systemd services für Motia Engine und iii Console - README mit Deployment-Info
This commit is contained in:
37
steps/notify_customer_step.py
Normal file
37
steps/notify_customer_step.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Notify Customer Step - sends a notification when a ticket has been triaged."""
|
||||
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
from motia import FlowContext, queue
|
||||
|
||||
config = {
|
||||
"name": "NotifyCustomer",
|
||||
"description": "Sends a notification when a ticket has been triaged",
|
||||
"flows": ["support-ticket-flow"],
|
||||
"triggers": [
|
||||
queue("ticket::triaged"),
|
||||
],
|
||||
"enqueues": [],
|
||||
}
|
||||
|
||||
|
||||
async def handler(input_data: Any, ctx: FlowContext[Any]) -> None:
|
||||
ticket_id = input_data.get("ticketId")
|
||||
assignee = input_data.get("assignee")
|
||||
priority = input_data.get("priority")
|
||||
title = input_data.get("title")
|
||||
|
||||
ctx.logger.info("Sending customer notification", {"ticketId": ticket_id, "assignee": assignee})
|
||||
|
||||
ticket = await ctx.state.get("tickets", ticket_id)
|
||||
customer_email = ticket.get("customerEmail", "") if ticket else ""
|
||||
redacted_email = re.sub(r"(?<=.{2}).(?=.*@)", "*", customer_email) if customer_email else "unknown"
|
||||
|
||||
ctx.logger.info("Notification sent", {
|
||||
"ticketId": ticket_id,
|
||||
"assignee": assignee,
|
||||
"priority": priority,
|
||||
"title": title,
|
||||
"email": redacted_email,
|
||||
})
|
||||
Reference in New Issue
Block a user