mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 03:09:50 +08:00
105 lines
3.9 KiB
Plaintext
105 lines
3.9 KiB
Plaintext
# Hub-and-Spoke Architecture Template
|
|
# ====================================
|
|
#
|
|
# This template demonstrates the Hub-and-Spoke pattern where a central
|
|
# agent_router (hub) routes conversations to specialized subagents (spokes).
|
|
#
|
|
# Pattern: Multi-purpose agents handling distinct request types
|
|
# Use when: Users may have different intents (orders, support, returns)
|
|
|
|
system:
|
|
messages:
|
|
welcome: "Welcome! I can help with orders, returns, or general support."
|
|
error: "I apologize, something went wrong. Let me try again."
|
|
instructions: "You are a customer service agent for an e-commerce company."
|
|
|
|
config:
|
|
agent_name: "HubAndSpokeAgent"
|
|
agent_label: "Customer Service Agent"
|
|
description: "Multi-purpose agent with hub-and-spoke architecture"
|
|
default_agent_user: "agent@yourorg.com" # REQUIRED: Change to valid Einstein Agent User
|
|
|
|
variables:
|
|
customer_id: linked string
|
|
source: @session.customerId
|
|
description: "Customer ID from session"
|
|
order_id: mutable string = ""
|
|
description: "Current order being discussed"
|
|
issue_resolved: mutable boolean = False
|
|
description: "Whether the issue has been resolved"
|
|
|
|
# ============================================================
|
|
# HUB: Central Router
|
|
# ============================================================
|
|
|
|
start_agent agent_router:
|
|
description: "Route to appropriate subagent based on user intent"
|
|
reasoning:
|
|
instructions: |
|
|
Determine what the customer needs and route accordingly:
|
|
- Order questions → orders subagent
|
|
- Return/refund requests → returns subagent
|
|
- General questions → support subagent
|
|
actions:
|
|
check_order: @utils.transition to @subagent.orders
|
|
description: "Customer wants to check order status"
|
|
process_return: @utils.transition to @subagent.returns
|
|
description: "Customer wants to return or refund"
|
|
general_help: @utils.transition to @subagent.support
|
|
description: "General support questions"
|
|
|
|
# ============================================================
|
|
# SPOKE: Orders Subagent
|
|
# ============================================================
|
|
|
|
subagent orders:
|
|
description: "Handle order status and tracking inquiries"
|
|
reasoning:
|
|
instructions: ->
|
|
| Help the customer with their order inquiry.
|
|
|
|
if @variables.order_id != "":
|
|
| Current order: {!@variables.order_id}
|
|
|
|
actions:
|
|
lookup_order: @actions.get_order_status
|
|
description: "Look up order details"
|
|
with order_id = @variables.order_id
|
|
back_to_hub: @utils.transition to @subagent.agent_router
|
|
description: "Return to main menu"
|
|
|
|
# ============================================================
|
|
# SPOKE: Returns Subagent
|
|
# ============================================================
|
|
|
|
subagent returns:
|
|
description: "Handle return and refund requests"
|
|
reasoning:
|
|
instructions: ->
|
|
| Help the customer with their return or refund request.
|
|
| Verify the order details before processing.
|
|
|
|
actions:
|
|
start_return: @actions.initiate_return
|
|
description: "Start a return process"
|
|
process_refund: @actions.process_refund
|
|
description: "Process a refund"
|
|
back_to_hub: @utils.transition to @subagent.agent_router
|
|
description: "Return to main menu"
|
|
|
|
# ============================================================
|
|
# SPOKE: Support Subagent
|
|
# ============================================================
|
|
|
|
subagent support:
|
|
description: "Handle general support questions"
|
|
reasoning:
|
|
instructions: |
|
|
Help the customer with general questions.
|
|
If the question requires specialized help, route appropriately.
|
|
actions:
|
|
escalate: @utils.escalate
|
|
description: "Transfer to human agent"
|
|
back_to_hub: @utils.transition to @subagent.agent_router
|
|
description: "Return to main menu"
|