ForcePilot/backend/package/yuxi/channel/extensions/helpscout/agent_prompt.py
Kris 432d5db970 feat(helpscout): 新增Help Scout客服工单渠道插件
完成Help Scout渠道的完整功能实现,包含API客户端、webhook处理、轮询同步、自动回复、工单标签分配、客户资料管理等核心能力,附带完整的配置Schema与插件元信息
2026-05-21 10:49:56 +08:00

73 lines
3.0 KiB
Python

from __future__ import annotations
class HelpScoutAgentPrompt:
@staticmethod
def build_system_prompt(context) -> str | None:
peer_name = getattr(context, "peer_name", "") or ""
mailbox_name = getattr(context, "mailbox_name", "") or ""
conversation_status = getattr(context, "conversation_status", "") or ""
customer_email = getattr(context, "customer_email", "") or ""
lines = [
"You are an AI assistant on Help Scout, a customer service help desk platform.",
"Your role is to ASSIST human agents — draft replies, analyze customer intent,",
"suggest priority levels, and provide context summaries.",
"NEVER autonomously send replies to customers.",
"ALWAYS set draft=true when composing a reply; human agents will review and send.",
"Conversation messages are in email/HTML format and may contain quoted email history.",
"Focus on the customer's latest message; ignore nested email quotes (lines starting with '>').",
]
if mailbox_name:
lines.append(f"You are assisting mailbox: {mailbox_name}")
if conversation_status:
lines.append(f"Current conversation status: {conversation_status}")
if peer_name:
lines.append(f"Customer: {peer_name}")
if customer_email and customer_email != peer_name:
lines.append(f"Customer email: {customer_email}")
return "\n".join(lines)
@staticmethod
def build_context_note(context) -> str:
mailbox_name = getattr(context, "mailbox_name", "") or ""
peer_name = getattr(context, "peer_name", "") or ""
conversation_id = getattr(context, "conversation_id", "") or ""
parts = ["Help Scout"]
if mailbox_name:
parts.append(mailbox_name)
if peer_name:
parts.append(peer_name)
if conversation_id:
parts.append(f"#{conversation_id}")
return f"[{' | '.join(parts)}]"
@staticmethod
def channel_format_instructions() -> str | None:
return (
"You are composing a reply in Help Scout (email format). "
"Use plain text or simple Markdown (**, *, lists, links). "
"Avoid complex HTML formatting unless specifically needed. "
"Always draft as a professional customer service email. "
"Include a polite greeting and signature."
)
@staticmethod
def build_draft_note(
customer_intent: str = "",
sentiment: str = "",
priority: str = "",
related_conversations: list[str] | None = None,
) -> str:
lines = ["--- AI Analysis ---"]
if customer_intent:
lines.append(f"Intent: {customer_intent}")
if sentiment:
lines.append(f"Sentiment: {sentiment}")
if priority:
lines.append(f"Suggested Priority: {priority}")
if related_conversations:
lines.append(f"Related: {', '.join(related_conversations)}")
return "\n".join(lines) if len(lines) > 1 else ""