ForcePilot/backend/package/yuxi/channel/extensions/intercom/session_guard.py

13 lines
520 B
Python
Raw Normal View History

from yuxi.channel.extensions.intercom.types import IntercomInboundEvent
class ConversationStateGuard:
@staticmethod
def should_respond(event: IntercomInboundEvent, account: dict) -> tuple[bool, str]:
state = event.conversation_state
if state == "closed" and account.get("auto_skip_closed", True):
return False, "conversation_closed"
if state == "snoozed" and account.get("auto_skip_snoozed", True):
return False, "conversation_snoozed"
return True, "ok"