Agent Script Blocks

A script consists of blocks where each block contains a set of properties. These properties can describe data or procedures. Agent Script contains several different block types.

Agent Script Blocks

This section gives you a high-level understanding of each block type.

System Block 

The system block contains general instructions for the agent. This information includes a list of messages that the agent should use during specific scenarios. welcome and error are required messages.

System Block
1system:
2    instructions:|
3        You are an AI agent. Have a friendly conversation with the user.
4
5    messages:
6        welcome: "Welcome, friend!"
7        error: "Whoops!"

Config Block 

The config block contains basic configuration information such as the agent label, the developer name, and the default agent user.

Config Block
1config:
2    developer_name: "Demo_Agent_1"
3    default_agent_user: "digitalagent.demo@salesforce.com"
4    agent_label: "Demo Agent"
5    description: "This is my demo agent"

Variables Block 

The variables block contains the list of global variables that the agent and script can use. See Variables.

Variables Block
1variables:
2    string_var: mutable string = "hello world"
3    hotel_info: mutable string = "Dreamforce Hotel"

You reference variables throughout the script by using the syntax @variables.<variable_name>.

Language Block 

The language block defines which languages the agent supports.

Language Block
1language:
2    default_locale: "en_US"
3    additional_locales: ""
4    all_additional_locales: False

Connection Block 

You can use the connection block to describe how this agent interacts with outside connections. For instance, this code snippet shows how the agent interacts with Enhanced Chat.

Connection Block
1connection messaging:
2    escalation_message: "One moment while I connect you to the next available service representative."
3    outbound_route_type: "OmniChannelFlow"
4    outbound_route_name: "agent_support_flow"
5    adaptive_response_allowed: True

You can use the connection block alongside the @utils.escalate command.

Topic Blocks 

The topic block allows you to specify the instructions, logic, and actions for an agent topic. A topic block contains a description, a list of actions, and the reasoning instructions.

Topic Block
1topic Order_Management:
2    description: "Handles order lookup, order updates, and summaries including status, date, location, items, and driver."
3
4    reasoning:
5        instructions: ->
6            if @variables.order_summary == "":
7                run @actions.lookup_current_order
8                with member_email=@variables.member_email
9                set @variables.order_summary=@outputs.order_summary
10
11            | Refer to the user by name {!@variables.member_name}.
12              Show their current order summary: {!@variables.order_summary} when conversation starts or if requested.
13              If they want past order info, ask for Order ID and use {!@actions.lookup_order}.
14
15        actions:
16            lookup_order: @actions.lookup_order
17                with query = ...
18                set @variables.order_summary=@outputs.order_summary
19                set @variables.order_id=@outputs.order_id
20
21            lookup_current_order: @actions.lookup_current_order
22                with member_email=@variables.member_email
23                set @variables.order_summary=@outputs.order_summary
24                set @variables.order_id=@outputs.order_id
25
26    actions:
27        lookup_order:
28            description: "Retrieve order details."
29            inputs:
30                query: string
31            outputs:
32                order_summary: string
33                order_id: string
34            target: "flow://SvcCopilotTmpl__GetOrdersByContact"
35
36
37        lookup_current_order:
38            description: "Retrieve current order details."
39            inputs:
40                member_email: string
41            outputs:
42                order_summary: string
43                order_id: string
44            target: "flow://SvcCopilotTmpl__GetOrderByOrderNumber"

These properties make up a topic block:

  • topic name: This value is the name of the topic that should accurately describe the scope and purpose of this topic in a few words. Because this value can’t have spaces, use snake_case to name the topic.
  • description: This property contains the description for this topic. This value should help the agent determine when to use this topic based on the user’s intent.
  • reasoning: This section contains information sent to the reasoning engine. Its primary properties are instructions and actions.
    • reasoning.instructions: This property contains guidance for the reasoning engine after it has decided that this topic is relevant to the user's request. The reasoning instructions can be a combination of logic instructions and prompt-based instructions. See Reasoning Instructions.
    • reasoning.actions: The list of tools that are applicable for the reasoning engine to use. This list can point to agent actions listed in the higher-level actions section, as well as other functionality available to the reasoning engine (such as transitioning to another topic, or setting a variable's value). See Tools (Reasoning Actions).
  • actions: This section defines the agent actions available from this topic. It contains a description of the action, the list of inputs and outputs, and the target location where this action resides. If you want to allow the reasoning engine to use one of these agent actions, you must also point to this action from the reasoning.actions section. See Actions.

Start Agent Block 

The start agent block (called the "Topic Selector" in Canvas view) is a topic that uses the start_agent prefix instead of the topic prefix. With every customer utterance, the agent begins execution at this block. The start_agent topic is used to initiate the conversation, and typically determines when to switch to the agent's other topics. This block handles topic classification, filtering, and routing.

Start Agent Block
1start_agent topic_selector:
2    description: "Welcome the user and determine the appropriate topic based on user input"
3    reasoning:
4        instructions: |
5            You are a topic selector for this assistant. Welcome the guest
6            and analyze their input to determine the most appropriate topic
7            to handle their request.
8        actions:
9            go_to_identity: @utils.transition to @topic.Identity_Verification
10                description: "Verifies user identity"
11                available when @variables.verified == False
12            go_to_order: @utils.transition to @topic.Order_Management
13                description: "Handles order lookup, refunds, and order updates."
14                available when @variables.verified == True
15            go_to_faq: @utils.transition to @topic.General_FAQ
16                description: "Handles various frequently asked questions."
17                available when @variables.verified == True
18            go_to_escalation: @utils.transition to @topic.Escalation
19                description: "Handles escalation to a human rep."
20                available when @variables.verified == True and @variables.is_business_hours == True

For more guidance on how to use the start agent block for topic routing and filtering, see Topic Classification and Routing in Salesforce Help.

Beta Feature

The new Agentforce Builder is a beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or your written Unified Pilot Agreement, and applicable terms in the Product Terms Directory. Use of this beta service consumes usage types per the Agentforce and Generative AI Usage and Billing documentation and is at the Customer's sole discretion.