# Flow Action Lookup Template # ============================ # # This template demonstrates the pattern for calling Flow actions # that return complex data types (SObjects, lists, custom types). # # Pattern: Data lookup and display using Flow actions # Use when: Fetching records from Salesforce (Cases, Orders, Accounts) # # CRITICAL: When defining Flow action outputs in Agentforce Assets: # - For SObject returns: complex_data_type_name = "lightning__recordInfoType" # - For list[string]: complex_data_type_name = "lightning__textType" # - For currency: complex_data_type_name = "lightning__currencyType" system: messages: welcome: "Hello! I can help you look up order information." error: "I apologize, something went wrong retrieving your data." instructions: "You are a customer service agent helping users look up their orders." config: agent_name: "FlowActionLookupAgent" agent_label: "Order Lookup Agent" description: "Agent demonstrating Flow action patterns with complex data types" default_agent_user: "agent@yourorg.com" # REQUIRED: Change to valid Einstein Agent User variables: # Customer context (from session) customer_id: linked string source: @session.customerId description: "Customer ID from session context" # Order data (populated by Flow action) order_id: mutable string = "" description: "Current order being viewed" order_status: mutable string = "" description: "Order status from lookup" order_total: mutable string = "" description: "Order total amount" order_date: mutable string = "" description: "Order date" # Error handling lookup_error: mutable boolean = False description: "Whether lookup encountered an error" start_agent entry: description: "Entry point - welcome and route to order lookup" reasoning: instructions: | Welcome the customer and offer to help with order lookups. actions: go_lookup: @utils.transition to @subagent.order_lookup description: "Start order lookup" # ============================================================ # ORDER LOOKUP SUBAGENT (Flow Action Pattern) # ============================================================ subagent order_lookup: description: "Look up order details using Flow action" reasoning: instructions: -> # POST-ACTION CHECK: Display results if order was found if @variables.order_status != "": | **Order Details** | - Order ID: {!@variables.order_id} | - Status: {!@variables.order_status} | - Total: {!@variables.order_total} | - Date: {!@variables.order_date} | | Is there anything else you'd like to know about this order? # ERROR CHECK: Handle lookup failures if @variables.lookup_error == True: | I couldn't find that order. Please check the order ID and try again. set @variables.lookup_error = False # INITIAL STATE: Ask for order ID if @variables.order_id == "": | What order would you like me to look up? | Please provide your order ID. actions: # Flow action with SObject return type # In Agentforce Assets, set outputs.order_record complex_data_type_name = "lightning__recordInfoType" lookup_order: @actions.Get_Order_Details description: "Look up order by ID" with order_id = ... # LLM extracts from user message include_in_progress_indicator: True progress_indicator_message: "Looking up your order..." set @variables.order_id = @outputs.order_id set @variables.order_status = @outputs.status set @variables.order_total = @outputs.total_amount set @variables.order_date = @outputs.order_date # Error handling: check if lookup failed if @outputs.found == False: set @variables.lookup_error = True # Flow action returning a list of strings # In Agentforce Assets, set outputs.product_names complex_data_type_name = "lightning__textType" get_items: @actions.Get_Order_Line_Items description: "Get list of items in the order" available when @variables.order_id != "" with order_id = @variables.order_id clear_search: @utils.setVariables description: "Search for a different order" with order_id = "" with order_status = "" with order_total = "" with order_date = "" escalate_now: @utils.escalate description: "Transfer to human agent"