Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Task 02: Build a topic that greets the customer, extracts refund details, and validates transactions

Introduction

To demonstrate credible business value, Zava’s COE must show agents can execute structured workflows, not just answer questions. Refund and cancellation scenarios are high-frequency, policy-sensitive interactions where a modular topic design reduces errors, improves consistency, and makes future changes safer.

Description

In this task, you’ll build the refund-initiator topic as a reusable workflow module. The topic retrieves order details from the sales transaction knowledge source, extracts key entities from the user request in a structured format, and applies eligibility logic for the 30-day return policy and Platinum flexibility. The topic also prepares a controlled handoff by storing only the required fields in a shared context variable for downstream topics.

Success criteria

  • A topic named refund-initiator exists and is saved with a clear description and trigger behavior aligned to refund-related intents.

  • The topic includes a generative answers node that:
    • Uses only the Zava Order Lookup (Sales Transactions) knowledge source.
    • Saves the model output into a variable for downstream processing.
    • Uses high content moderation settings as specified.
  • An AI prompt is implemented to extract entities as structured JSON without extra text, and output is stored in jsEntityExtraction.

Key steps

  1. On the command bar for the agent, select Topics.

    udh37nuz.jpg

  2. On the Topics page, select Add a topic and then select From blank.

    wzvqonqn.jpg

  3. Change the name from Untitled to refund-initiator and then press the Enter key to save the change.

    spo953cw.jpg

    8f2dtrfo.jpg

  4. In the Describe what the topic does field, enter the following text:

     This topic must activate without exception for any customer request involving refunds, returns, replacements, defective or damaged items, or order cancellations.
    
  5. On the command bar for the agent, select Save.

  6. If the Test pane is not open, on the command bar for the agent, select Test.

    pyy4za3d.jpg

  7. In the Test pane, select Start new test session (the + sign).

    47qkmh10.jpg

  8. Submit the following prompt:

     How can I request a refund for order TXN‑2008, which I no longer need?
    
  9. Review the response.

    Your output may vary slightly from the screenshot provided below.

    d4x251sa.jpg


02: Optimize the agent instructions for handling customer requests

  1. On the command bar for the agent, select Overview.

    0pis0roq.jpg

  2. On the Instructions tile, select Edit.

    r0qhfwc4.jpg

  3. Locate “1. First, call the [refund‑initiator] topic.” in the agent description.

    cmb16n10.jpg

  4. Highlight and delete refund-initiator, then enter /. From the list of suggestions, select refund-initiator.

    3cz90jhg.jpg

  5. On the Instructions tile, select Save.

    bdhshwtc.jpg

  6. On the command bar for the agent, select Topics and then select refund-initiator.

    8q73mg8i.jpg

  7. Below the Trigger node, select Add node (the + sign) and then select Advanced. Select Generative answers.

    kzeytax4.jpg

  8. Select the title for the node.

  9. In the Title field, enter Fetch Customer Order Details.

    i9iz92l9.jpg

    An error message may display. This is expected. You have not yet supplied input to the node but you can correct that later in the task.

  10. At the top right of the node, select the ellipses () and then select Properties.

    i9rel29r.jpg

  11. In the Create generative answers properties pane, in the Knowledge sources section, set Search only selected sources to On.

    8rtgz66x.jpg

  12. In the list of knowledge sources, select Zava Order Lookup (Sales Transactions).

    vz0ffvyk.jpg

  13. Move down to the Content moderation level section and then select Customize.

    gp96c8le.jpg

  14. If necessary, set the level to High.

    rj5j72qv.jpg

  15. In the text field below the content moderation level field, enter the following text:

     Below is the customer's message:
     Activity.Text
    	
     Instructions:
     When responding to a customer request that includes a transaction or order ID, begin with a brief empathy statement such as: "I'm sorry for the inconvenience you've experienced." Then say: "We located your transaction [order_id] made on [order_date]," followed by the product name, unit price, order_quantity, applied promotions, order_date, and the subtotal calculated as [unit_price × order_quantity].
    	
     Keep your response as one concise paragraph. Do not make decisions on the customer's behalf. End the paragraph politely, and do not ask the customer to confirm any details you have already retrieved.
    

    2olj9kx3.jpg

  16. Move down to the bottom of the pane and then select Advanced.

    7olrvklp.jpg

  17. Ensure that the Send a message checkbox is selected.

  18. Set Save LLM response to Text only.

  19. In the Save bot response as field, select Select a variable.

    7h705us5.jpg

  20. Select Create new.

  21. In the Save bot response as field, select Var1.

    ozzj7crr.jpg

  22. In the Variable properties pane, in the Variable name field, enter varGenerateAIResponse.

    2ddsefz5.jpg

  23. At the top right of the Variable properties pane, select X to close the pane.

  24. In the Fetch Customer Order Details node, in the Input field, select the ellipses ().

    z1bnupre.jpg

  25. In the Select a variable dialog, select System and then select Activity.Text.

    8nsg0u2x.jpg

    The Missing required property ‘UserInput’ message should no longer be visible.

  26. Below the Fetch Customer Order Details node, add a Send a message node.

    8nxfxu8g.jpg

  27. In the text field for the Send a message node, select Insert variable ({X}).

    s6f2nsoq.jpg

  28. In the Select a variable dialog, select System and then select Activity.value.

    frvpde7s.jpg

  29. On the command bar for the agent, select Save.

    zgjd9vda.jpg

  30. If the Test pane is not open, on the command bar for the agent, select Test.

    pyy4za3d.jpg

  31. In the Test pane, select Start new test session (the + sign).

    47qkmh10.jpg

  32. Submit the following prompt:

     How can I request a refund for order TXN‑2008, which I no longer need?
    
  33. Review the response. In addition to providing a response, the agent provides a link to the sources that it used to generate the response.

    4xq6wccl.jpg


03: Implement AI Builder

You’ve successfully verified the transaction and gathered its details. To move forward with a refund, return, or cancellation, you need to extract the relevant entities from the customer’s request. There are several ways to accomplish this, but the most effective and reliable approach is to use AI Prompt Builder.

  1. Delete the Message node that you added in the previous section of this task.

    To delete the node, select the ellipses () at the top right of the node and then select Delete.

  2. Below the Fetch Customer Order Details node, select New node (the + sign). Select Add a tool and then select New Prompt.

    h0v3664y.jpg

  3. In the dialog that displays, select the title field.

    2jii4cd7.jpg

  4. Change the title to EntityExtraction-@lab.CloudPortalCredential(User1).AccessToken and press the Enter key to accept the change.

    6oci2mrq.jpg

  5. In the Model field, select GPT-4.1 mini.

    0q942xe2.jpg

  6. In the Instructions area, in the text field below the model selector, enter the following instructions text:

     Extract the following fields from [USER_INPUT] and return the data as JSON only:
    
     - order_id: the transaction or order ID (e.g., TXN-2008)
     - order_date: the purchase date in ISO format (YYYY-MM-DD)
     - unit_price: number value only (no symbols)
     - quantity: integer quantity purchased
     - subtotal: calculated as unit_price × quantity, number only
     - is_platinum: true if the text explicitly states Platinum loyalty tier; false if the text explicitly states a non‑Platinum tier; null if not mentioned
     - isWithin30DayWindow: true if the text explicitly states the purchase is within 30 days of eligibility; false if explicitly outside 30 days; null if not stated
    
     Rules:
     - Return ONLY a JSON object. No explanations, no natural language.
     - If a field is missing, return null for that field.
     - Never change the meaning or infer imaginary values.
     - Use only data explicitly found in USER_INPUT.
    
     Return ONLY JSON in this exact format:
    
     {
     "order_id": "...",
     "order_date": "...",
     "unit_price": ...,
     "quantity": ...,
     "subtotal": ...,
     "is_platinum": ...,
     "isWithin30DayWindow": ...
     }
    

    rg4ibd1l.jpg

  7. In the instructions that you just pasted, locate and select the [USER_INPUT] placeholder.

    mulu5se0.jpg

  8. Select + Add content.

    tdm5xnf4.jpg

  9. In the dialog, in the Input section, select Text.

    xw13q4j1.jpg

  10. In the dialog that displays, in the Name field, enter USER_INPUT.

  11. In the Sample data field, enter the following text and then select Close:

     I'm sorry for the inconvenience you've experienced. We located your transaction TXN-2008 made on 02/07/2025, which includes Eco Water Bottle 24oz at a unit price of $14.99, quantity 2, under loyalty tier None, with promotions applied: PRM-NEW10; PRM-5OFF; PRM-B2G10, resulting in a subtotal of $29.98 before discounts. As this purchase was made nearly a year ago and your loyalty tier is not Platinum, it falls outside the standard 30-day return window, making it ineligible for a refund under our policy. Platinum members enjoy VIP flexibility without the 30-day limit, but this does not apply here.​	
    

    gspmiucb.jpg

  12. In the EntityExtractiion dialog, in the Model response pane, select Output and then select JSON.

    7jbjevr3.jpg

  13. In the Instructions pane, select Test.

    v824edzn.jpg

  14. In the Model response pane, verify that the response contains well-formed JSON code.

    05853xn1.jpg

  15. Select Save.

    2ndvrnrl.jpg

  16. On the topic page, in the Prompt node, in the Input section, select the ellipses ().

    0shdlcio.jpg

  17. In the Select a variable dialog, select Custom and then select varGenerateAIResponse. Close the dialog.

    2792nzww.jpg

  18. In the Prompt node, in the Output section, select Select a variable.

    ypno20j8.jpg

  19. In the Select a variable dialog, select Create a new variable.

    l7qptm05.jpg

  20. In the Output section, select Var1.

    gu1phdom.jpg

  21. In the Variable properties pane, in the Name field, enter jsEntityExtraction.

    7dw63msq.jpg

  22. Close the Variable properties pane.

  23. Add a Send a message node below the Prompt node.

  24. In the Message node, select Insert PowerFx expression (fx).

  25. In the Enter formula dialog, in the fx field, enter Topic.jsEntityExtraction.structuredOutput.

    u3oayqc3.jpg

  26. Select Insert.

    35hak0ms.jpg

  27. On the command bar for the agent, select Save.

    hvnb9jtw.jpg

  28. If the Test pane is not open, on the command bar for the agent, select Test.

    pyy4za3d.jpg

  29. In the Test pane, select Start new test session (the + sign).

    47qkmh10.jpg

  30. Submit the following prompt:

     How can I request a refund for order TXN‑2008, which I no longer need?
    
  31. Review the response. The AI prompt builder extracted only the essential order details, returning a clean structured summary of the transaction.

  32. Delete the Message node.


04: Add conditional logic

  1. Below the Prompt node, select Add node (the + icon), go to Variable management, and choose Set a variable value.

  2. In the Set variable value node, in the Set variable field, select Select a variable.

  3. Select Create a new variable.

  4. Select Var1. In the Variable properties pane, in the Variable name field, enter isReturnEligible.

  5. Close the Variable properties pane.

  6. In the To value field, in the Enter or select a value field, select the ellipses ().

  7. In the Select a variable dialog, select Formula.

  8. Enter the following formula and then select  Insert.

     Topic.jsEntityExtraction.structuredOutput.isWithin30DayWindow = true || Topic.jsEntityExtraction.structuredOutput.is_platinum = true
    

    kldf3qit.jpg

  9. Below the Set variable value node, select Add node (the + icon), and then choose Add a condition.

    7etrdso1.jpg

  10. In the Condition node, select the ellipses () and then select Insert new condition.

    thzp75a8.jpg

  11. Configure the leftmost Condition node as per the following screenshot, select Select a variable, then select IsReturnEligible, and set it to true:

    3sizkpr5.jpg

  12. Configure the other Condition node as per the following screenshot, select Select a variable, then select IsReturnEligible, and set it to false:

    rljsh5q3.jpg

  13. Add a Send a message node below the false condition node.

    gm03d2rk.jpg

  14. In the Message node, enter the following text:

     We always strive to support our customers. Although this request isn't eligible, we're here to help with anything else you need.
    

    6i7xeo23.jpg

  15. Below the Message node, select Add node (the + icon), go to Topic management, and then select End conversation.

    4hjzlvil.jpg

  16. On the command bar for the topic, select Save.

  17. Create a new test session and submit the following prompt:

     How can I request a refund for order TXN‑2008, which I no longer need?
    

    k9ivj9m4.jpg

  18. Below the true condition node, select Variable management, and then Set variable value.

    qotnhrzi.jpg

  19. In the Set variable field, create a new variable named redRefundGlobalShareContext.

  20. In Variable properties pane, in the Usage section, select Global (any topic can access).

    rtjqbcxs.jpg

  21. Close the Variable properties pane.

  22. In the Set variable value node, in the To value field, select the ellipses ().

    2h6fjl1j.jpg

  23. In the Select a variable dialog, select the Formula tab.

    5s78dq6i.jpg

  24. In the fx field, enter Topic.jsEntityExtraction.structuredOutput and then select Insert.

    7lygmd65.jpg

    Expected output

    9ngslz40.jpg

  25. On the command bar for the agent, select Save and then select Publish.

    j4d3pgps.jpg