Repository navigation
[#199] Auto-close stale escalations with no officer response - #200
Merged
Merged
Conversation
…sponse Add a daily Celery beat task (20:00 EAT / 17:00 UTC) that closes open tickets older than ticket_auto_close.stale_hours (default 24) with no officer reply since the ticket was created. Tickets with any officer reply are never auto-closed; auto-closed tickets keep resolved_by NULL. Each affected farmer is notified once via the ticket_auto_close Twilio template, falling back to free text only inside the WhatsApp 24h window. Parameterise the responder role name via officer_label (e.g. "Health Worker"), also used by the existing ticket_closed message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #199
Summary
tasks.ticket_tasks.auto_close_stale_ticketsat 20:00 EAT (17:00 UTC). It closes open tickets older thanticket_auto_close.stale_hours(default 24) that have no officer reply, meaning nofrom_source = USERmessage for that customer since the ticket was created.resolved_by = NULL, so they can be told apart from officer-resolved tickets.ticket_auto_closeTwilio template ({{1}}= officer label), ENHX80d2…d392/ SWHX58b6…c3ticket_auto_closedinwhatsapp_messages.json), only inside the WhatsApp 24h windowofficer_labelconfig ({"en": "Extension Officer", "sw": "Afisa Ugani"}) parameterises the role name, e.g. "Health Worker" for the health sector. The existingticket_closedmessage now uses it too; it previously hardcoded "extension officer".ticket_auto_close.enabled.docs/TICKET_AUTO_CLOSE.md.Deviation from the issue
No
ticket_resolvedWebSocket event is emitted. Socket.IO connections live in the backend process with no Redis manager, so the Celery worker cannot reach dashboard clients. Auto-closed tickets appear as resolved on the next reload.Before deploying
officer_labelandwhatsapp.templates.ticket_auto_close(sid,sid_sw) to the Vault-injectedconfig.jsonfor the test and production clusters, then restartbackendandcelery-workerticket_auto_close.enabled: falsein Vault to hold it.Test plan
tests/test_ticket_auto_close.py: selection (stale, answered, reply before ticket, under threshold, configurable threshold, already resolved), notification (template, free text in window, outside window, officer label, Swahili, one message per farmer, send failure), disabled flag, beat scheduletest_tickets.py: manual resolve message uses the officer label🤖 Generated with Claude Code