diff --git a/src/dispatch/case/flows.py b/src/dispatch/case/flows.py index 6389eb38144b..f03db629b870 100644 --- a/src/dispatch/case/flows.py +++ b/src/dispatch/case/flows.py @@ -294,7 +294,19 @@ def case_new_create_flow( elif case.event: # no one has been paged, inform the channel that they can # engage the oncall if the priority changes - send_event_paging_message(case, db_session) + oncall_name = "the relevant team" + + try: + if case.case_type and case.case_type.oncall_service: + oncall_service = service_service.get_by_external_id( + db_session=db_session, + external_id=case.case_type.oncall_service.external_id, + ) + oncall_name = oncall_service.name + except Exception as e: + log.error(f"Failed to get oncall service: {e}. Falling back to default oncall_name string.") + + send_event_paging_message(case, db_session, oncall_name) if case and case.case_type.auto_close: # we transition the case to the closed state if its case type has auto close enabled diff --git a/src/dispatch/case/messaging.py b/src/dispatch/case/messaging.py index 2bbb9ee799a1..8b28744d6969 100644 --- a/src/dispatch/case/messaging.py +++ b/src/dispatch/case/messaging.py @@ -377,7 +377,7 @@ def send_case_welcome_participant_message( log.debug(f"Welcome ephemeral message sent to {participant_email}.") -def send_event_paging_message(case: Case, db_session: Session): +def send_event_paging_message(case: Case, db_session: Session, oncall_name: str) -> None: """ Sends a message to the case conversation channel to notify the reporter that they can engage with oncall if they need immediate assistance. @@ -400,7 +400,7 @@ def send_event_paging_message(case: Case, db_session: Session): "type": "section", "text": { "type": "mrkdwn", - "text": f"This event was reported and the team will respond during normal business hours. If you end up needing immediate assistance, you can engage the oncall with `{engage_oncall_command}`.", + "text": f"This event was reported and the team will respond during normal business hours. If you end up needing immediate assistance, you can engage `{oncall_name}` with `{engage_oncall_command}` and selecting the 'Page' option.", }, }, ]