新增 Intercom 渠道扩展,支持在 Yuxi 平台中集成 Intercom 客服渠道。 包含以下功能模块: - client: Intercom API 客户端封装 - config: 渠道配置管理 - gateway: SSE/WebSocket 网关接入 - webhook: Webhook 事件处理 - streaming: 流式消息处理 - format: 消息格式转换 - outbound: 外发消息管理 - handoff: 转人工会话切换 - pairing: 用户配对与绑定 - security: 安全签名校验 - dedupe: 消息去重 - monitor: 渠道状态监控 - status: 会话状态管理 - session_guard: 会话防护 - types: 类型定义
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
INTERCOM_API_BASES = {
|
||
"us": "https://api.intercom.io",
|
||
"eu": "https://api.eu.intercom.io",
|
||
"au": "https://api.au.intercom.io",
|
||
}
|
||
DEFAULT_DATACENTER = "us"
|
||
INTERCOM_API_VERSION = "2.15"
|
||
|
||
INTERCOM_DEFAULT_TIMEOUT = 30.0
|
||
INTERCOM_MAX_RETRIES = 3
|
||
INTERCOM_RETRY_BASE_DELAY = 1.0
|
||
INTERCOM_RETRY_MAX_DELAY = 8.0
|
||
|
||
INTERCOM_DEDUPE_TTL_SECONDS = 60
|
||
INTERCOM_DEDUPE_MAX_SIZE = 10000
|
||
|
||
INTERCOM_TEXT_CHUNK_LIMIT = 40000
|
||
|
||
INTERCOM_BLOCK_STREAMING_CHUNK_MIN_CHARS = 500
|
||
INTERCOM_BLOCK_STREAMING_CHUNK_MAX_CHARS = 2000
|
||
|
||
INTERCOM_WEBHOOK_TOPICS_HANDLED = frozenset(
|
||
[
|
||
# 用户消息事件
|
||
"conversation.user.created",
|
||
"conversation.user.replied",
|
||
# 管理员事件(P0 新增)
|
||
"conversation.admin.closed",
|
||
"conversation.admin.opened",
|
||
"conversation.admin.snoozed",
|
||
"conversation.admin.unsnoozed",
|
||
"conversation.admin.assigned",
|
||
"conversation.admin.replied",
|
||
"conversation.admin.single.created",
|
||
# 其他 Bot / Operator 回复(P0 新增)
|
||
"conversation.operator.replied",
|
||
# 会话状态事件(P1 新增)
|
||
"conversation.deleted",
|
||
"conversation.priority.updated",
|
||
"conversation.rating.added",
|
||
"conversation.read",
|
||
# 消息事件(P1 新增)
|
||
"conversation_part.redacted",
|
||
"conversation_part.tag.created",
|
||
]
|
||
)
|
||
|
||
INTERCOM_CONVERSATION_STATES = frozenset(["open", "snoozed", "closed"])
|
||
|
||
INTERCOM_PART_TYPES = frozenset(["comment", "note", "assignment", "close", "open", "snooze"])
|
||
|
||
INTERCOM_DM_POLICY_OPEN = "open"
|
||
INTERCOM_DM_POLICY_PAIRING = "pairing"
|
||
INTERCOM_DM_POLICY_ALLOWLIST = "allowlist"
|
||
INTERCOM_DM_POLICY_DISABLED = "disabled"
|
||
|
||
INTERCOM_HANDOFF_POLICY_IGNORE = "ignore"
|
||
INTERCOM_HANDOFF_POLICY_NOTE_ONLY = "note_only"
|
||
INTERCOM_HANDOFF_POLICY_CONTINUE = "continue"
|
||
|
||
INTERCOM_AGENT_PROMPT_RULES = [
|
||
"Your response will be sent to Intercom Messenger as an admin reply.",
|
||
"The message format is HTML. Use <strong> for bold, <em> for italic.",
|
||
'Use <a href="URL">text</a> for links.',
|
||
"Use <ul><li>item</li></ul> for unordered lists.",
|
||
"Use <ol><li>item</li></ol> for ordered lists.",
|
||
"Use <code> for inline code and <pre><code> for code blocks.",
|
||
"Do not use markdown headings (use <p><strong>heading</strong></p> instead).",
|
||
"Do not use pipe tables (use <pre> for table-like text).",
|
||
"Keep responses friendly, professional, and solution-oriented.",
|
||
"Identify yourself as an AI assistant when relevant.",
|
||
]
|