新增 Intercom 渠道扩展,支持在 Yuxi 平台中集成 Intercom 客服渠道。 包含以下功能模块: - client: Intercom API 客户端封装 - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - streaming: 流式消息处理 - format: 消息格式转换 - outbound: 外发消息管理 - handoff: 转人工会话切换 - pairing: 用户配对与绑定 - security: 安全签名校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - session_guard: 会话防护 - types: 类型定义
13 lines
520 B
Python
13 lines
520 B
Python
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"
|