Open the main FastAPI app file (the one that defines require_api_key, require_auth, /api/lia/inbound, etc. – currently the dashboard server file). 1) Update imports from app.lia_rules Find the import from app.lia_rules (it currently imports things like LIA_TIER_BEHAVIOUR, LIA_TONE_GUIDELINES, classify_inbound_tier, select_eot_intro) and make sure it ALSO imports LIA_NUDGE_TEMPLATES, for example: from app.lia_rules import ( LIA_TIER_BEHAVIOUR, LIA_TONE_GUIDELINES, classify_inbound_tier, select_eot_intro, LIA_NUDGE_TEMPLATES, ) If the import is currently on one line, expand it to a multi-line import as above. 2) Add a Pydantic model for the nudge request Make sure this file imports BaseModel from pydantic (it already does for WhatsAppMessage). Then, somewhere near the other models (e.g. near WhatsAppMessage), add: class LiaNudgeRequest(BaseModel): conversation_id: str nudge_type: str = "nudge_1" # e.g. "nudge_1" or "nudge_2" payments_remaining: int | None = None # reserved for future use 3) Add the /api/lia/nudge endpoint Below the existing /api/lia/inbound endpoint (or near the other Lia-related APIs), add: @app.post("/api/lia/nudge", dependencies=[Depends(require_api_key)]) async def lia_nudge(payload: LiaNudgeRequest): """ Generate and log a nudge message for a conversation, without needing an inbound customer message. This is designed to be called from Make.com using the x-api-key. It returns the text Lia should send, and logs it into dp_messages. """ # Map simple nudge_type to the internal template key mapping = { "nudge_1": "NUDGE_1_EOT", "nudge_2": "NUDGE_2_EOT", "NUDGE_1_EOT": "NUDGE_1_EOT", "NUDGE_2_EOT": "NUDGE_2_EOT", } template_key = mapping.get(payload.nudge_type) if not template_key: raise HTTPException(status_code=400, detail="Invalid nudge_type") # Fetch the template text try: reply_text = LIA_NUDGE_TEMPLATES[template_key] except KeyError: raise HTTPException(status_code=500, detail="Nudge template not configured") # Log the nudge as an outbound Lia message try: await insert_message( conversation_id=payload.conversation_id, direction="outbound", channel="whatsapp", sender="lia", message_body=reply_text, template_key=template_key, mode=payload.nudge_type, ab_variant=None, ) except Exception as e: print(f"Failed to insert nudge message: {e}") raise HTTPException(status_code=500, detail="Failed to log nudge message") return { "conversation_id": payload.conversation_id, "nudge_type": payload.nudge_type, "template_key": template_key, "reply": reply_text, } 4) Do not change any existing endpoints or business logic. Only add the model + new endpoint + updated import. 5) Save the file and restart the server. Confirm there are no errors.