# Multi-Topic Agent Template
# An agent with multiple conversation topics (hub-and-spoke pattern)
# Users are routed to specialized topics based on their needs
#
# Usage: Replace {{placeholders}} with your values
# Required: agent_name, default_agent_user, agent_label, description
# Required: At least 2 topics with label and description

system:
	instructions: "{{SystemInstructions}}"
	messages:
		welcome: "{{WelcomeMessage}}"
		error: "I'm sorry, I encountered an issue. Please try again."

config:
	agent_name: "{{AgentApiName}}"
	default_agent_user: "{{AgentUser}}"
	agent_label: "{{AgentLabel}}"
	description: "{{AgentDescription}}"

variables:
	EndUserId: linked string
		source: @MessagingSession.MessagingEndUserId
		description: "Messaging End User ID"
	RoutableId: linked string
		source: @MessagingSession.Id
		description: "Messaging Session ID"
	ContactId: linked string
		source: @MessagingEndUser.ContactId
		description: "Contact ID"
	user_intent: mutable string
		description: "What the user is trying to accomplish"

language:
	default_locale: "en_US"
	additional_locales: ""
	all_additional_locales: False

start_agent topic_selector:
	label: "Topic Selector"
	description: "Routes users to the appropriate topic based on their needs"

	reasoning:
		instructions: ->
			| Determine what the user needs help with.
			| Route them to the most appropriate topic.
			| If unclear, ask clarifying questions.
		actions:
			go_to_topic_one: @utils.transition to @topic.{{topic_one_name}}
			go_to_topic_two: @utils.transition to @topic.{{topic_two_name}}
			go_to_topic_three: @utils.transition to @topic.{{topic_three_name}}
			go_to_farewell: @utils.transition to @topic.farewell
			go_to_escalation: @utils.transition to @topic.escalation

topic {{topic_one_name}}:
	label: "{{TopicOneLabel}}"
	description: "{{TopicOneDescription}}"

	reasoning:
		instructions: ->
			| {{TopicOneInstructions}}
		actions:
			back_to_menu: @utils.transition to @topic.topic_selector

topic {{topic_two_name}}:
	label: "{{TopicTwoLabel}}"
	description: "{{TopicTwoDescription}}"

	reasoning:
		instructions: ->
			| {{TopicTwoInstructions}}
		actions:
			back_to_menu: @utils.transition to @topic.topic_selector

topic {{topic_three_name}}:
	label: "{{TopicThreeLabel}}"
	description: "{{TopicThreeDescription}}"

	reasoning:
		instructions: ->
			| {{TopicThreeInstructions}}
		actions:
			back_to_menu: @utils.transition to @topic.topic_selector

topic farewell:
	label: "Farewell"
	description: "Ends the conversation gracefully"

	reasoning:
		instructions: ->
			| Thank the user for reaching out.
			| Wish them a great day.
			| Let them know they can return anytime.

topic escalation:
	label: "Escalation"
	description: "Handles requests to transfer to a live human agent"

	reasoning:
		instructions: ->
			| If the user explicitly asks to speak with a human, escalate.
			| Acknowledge the request and transfer gracefully.
		actions:
			escalate_to_human: @utils.escalate
				description: "Escalate to a human agent"
