Topic Block utility

  • Release version: Zurich
  • Updated August 6, 2025
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Topic Block utility

    The Topic Block utility in Virtual Agent conversations allows you to embed reusable topic blocks that perform specific functions or subflows within a calling topic. It enables modular conversation design by running predefined steps and passing variables between topics.

    Show full answer Show less

    Key Features

    • Node name: Automatically assigned based on the selected topic block or manually set when using dynamic Topic Blocks.
    • Use dynamic Topic Block toggle: When activated, allows programmatic selection of topic blocks based on conditions or scripts, enabling flexible invocation without a fixed one-to-one input-output mapping.
    • Topic block selection: Choose from a list of published topic blocks or define dynamic conditions to select them.
    • Input mapping: Define variables that serve as inputs to the selected topic block. These can include strings, records, scripts, or objects. Dynamic Topic Blocks require manual input mapping configuration.
    • Output mapping: Specify variables returned by the topic block to be used later in the conversation flow. Similar to input mapping, outputs can be manually configured for dynamic Topic Blocks.
    • Advanced options: Include conditional logic to hide or display the Topic Block node based on evaluated expressions, supporting no-code and low-code configurations.

    Using Dynamic Topic Blocks

    Activating the dynamic setting allows you to:

    • Choose which topic block to invoke at runtime using scripts or conditions.
    • Pass a flexible set of inputs, not restricted to predefined mappings.
    • Handle complex scenarios where different topic blocks are called based on user input or other variables.

    Example: A single dynamic Topic Block can decide whether to run a "NormalPasswordReset" or "TwoFactorReset" topic block based on a condition checking if two-factor authentication is required. Inputs and outputs are mapped accordingly to handle both cases within one node.

    Example dynamic script: A script returns the topic block name based on input, such as selecting troubleshooting topics for different car makes ("Ford", "Toyota", or a general topic), enabling flexible and context-aware conversation flows.

    Practical Benefits for ServiceNow Customers

    • Reuse common conversation flows efficiently by embedding topic blocks, reducing duplication and maintenance.
    • Implement dynamic conversation logic that adapts to user inputs or conditions without creating multiple separate topics.
    • Maintain clear input/output mappings to ensure smooth data passing and state management within Virtual Agent conversations.
    • Leverage low-code/no-code expressions to control when and how topic blocks appear, enhancing user experience.

    Use a Topic Block in a Virtual Agent conversation to perform a specific function or subflow that runs certain steps in a calling topic.

    Topic Block utility properties

    For more information, see Add a reusable topic block to a calling topic or topic block.

    Property Description
    Node name Name of the topic block node. The name is automatically assigned based on the topic block that you select. For example, if you choose the Acme Contextual Search topic block, the Name is Acme Contextual Search.

    With Use dynamic Topic Block active, input a name of your choice.

    Use dynamic Topic Block Set this toggle to activate dynamic Topic Block options.
    Topic block A list of published topic blocks. Select a topic block to add to the calling topic.

    With Use dynamic Topic Block active, use the condition builder to input a condition or script instead.

    Input mapping

    The variables to be used as input to the selected topic block. In this example, input mapping variables include catalog item ID, execute contextual search, confirm catalog item, and show end state card.

    Input mapping variables.

    The contents of this area change according to the topic block you selected. Options may include string input, referenced records, scripts, and so forth.

    With Use dynamic Topic Block active, you add all input mappings manually instead by selecting the Manage inputs to define icon Manage inputs to define icon.. Inputs are handled similarly to the Input Parameters dialog box in the Start segment of a reusable topic block.

    Output mapping

    The variables to be output by the selected topic block. For example, the following image has example variables that are enabled:

    In this example, output mapping variables include record ID, record table, and user option variables.

    The contents of this area change according to the topic block you selected.

    With Use dynamic Topic Block active, you add all input mappings manually instead by selecting the Manage outputs to define icon Manage outputs to define icon.. Inputs are handled similarly to the Input Parameters dialog box in the Start segment of a reusable topic block.

    Advanced
    Hide this node
    Conditionally use this node if

    A no-code condition statement or low-code script that specifies a condition for presenting this node in the conversation. The condition must evaluate to true.

    Example Topic Block utilities

    The following Topic Block utility properties include the reference to an available topic block, input mapping variables to the topic block, and the output variables that the topic block will pass.

    Example topic block.

    The following Topic Block utility properties have the Use dynamic Topic Block toggle switch turned on.

    Example topic block.

    Using dynamic Topic Blocks

    Toggling the dynamic setting on the Topic Block enables you to programmatically choose which topic block or blocks to invoke, based on any number of conditions. You can pass in a dynamic set of inputs without an explicit, one-to-one match for a Topic Block definition.

    For example, assume you have two Topic Blocks. One sets your password by taking your username and returning a success or fail message. The other resets your password, but requires that you send two-factor authentication (2FA) token with the request before returning a success or fail message and a temporary password.

    You can create two separate Topic Block invocations to handle the password-reset procedure, or you can create one Topic Block with the dynamic setting active and defined as follows:

    • Add a script that checks if the reset type is includesTwoFactor = true. If the statement evaluates to true, then you return TwoFactorReset, otherwise you return NormalPasswordReset.
    • Define two input mappings: password and twoFactorToken, both set equal to an object passed in which contains their values.
    • Define two output mappings: successful and tempPass, the latter of which is only set if it exists in the return value for the Topic Block.
    • Define two output nodes to output success or failure, and an output to confirm to you whether the tempPass value is true.

    Example dynamic Topic Block expression

    (function execute() {
        /* Return the name of the topic block to run. For example:
            switch (vaVars.car_make) {
                case 'Ford':
                    return 'Ford troubleshooting';
                case 'Toyota':
                    return 'Toyota troubleshooting';
                default:
                    return 'General car troubleshooting';
            }
        */
    })()

    The script in the dynamic Topic Block expression returns a value based on your input. In this example, if you input Ford or Toyota, the Virtual Agent will call for the appropriate troubleshooting topic. If you input any other value, the Virtual Agent returns a general troubleshooting topic instead.