{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":5297,"path":"conversational-interfaces/virtual-agent/va-topic-blocks.md","title":"Topic Block utility","bundle":null,"doc_type":null,"release":"australia","body":"\n# Topic Block utility\n\nUse a Topic Block in a Virtual Agent conversation to perform a specific function or subflow that runs certain steps in a calling topic.\n\n## Topic Block utility properties\n\nFor more information, see [Add a reusable topic block to a calling topic or topic block](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/conversational-interfaces/virtual-agent/add-topic-blocks-to-topic.md).\n\n<table id=\"table_nff_y1b_3db\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nNode name\n\n</td><td>\n\nName 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.\n\n</td></tr><tr><td>\n\nUse dynamic Topic Block\n\n</td><td>\n\nSet this toggle to activate dynamic Topic Block options.\n\n</td></tr><tr><td>\n\nTopic block\n\n</td><td>\n\nA 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.\n\n</td></tr><tr><td>\n\nInput mapping\n\n</td><td>\n\nThe 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.\n\n \\[Omitted image \"map-tb-input-values.png\"\\] Alt text: Input mapping variables.\n\n The contents of this area change according to the topic block you selected. Options may include string input, referenced records, scripts, and so forth.\n\n With **Use dynamic Topic Block** active, you add all input mappings manually instead by selecting the Manage inputs to define icon \\[Omitted image \"manage-inputs-outputs.png\"\\] Alt text: Manage inputs to define icon.. Inputs are handled similarly to the Input Parameters dialog box in the Start segment of a [reusable topic block](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/conversational-interfaces/virtual-agent/create-topic-blocks.md).\n\n</td></tr><tr><td>\n\nOutput mapping\n\n</td><td>\n\nThe variables to be output by the selected topic block. For example, the following image has example variables that are enabled:\n\n \\[Omitted image \"map-output-vars-tb.png\"\\] Alt text: In this example, output mapping variables include record ID, record table, and user option variables.\n\n The contents of this area change according to the topic block you selected.\n\n With **Use dynamic Topic Block** active, you add all input mappings manually instead by selecting the Manage outputs to define icon \\[Omitted image \"manage-inputs-outputs.png\"\\] Alt text: Manage outputs to define icon.. Inputs are handled similarly to the Input Parameters dialog box in the Start segment of a reusable topic block.\n\n</td></tr><tr><td class=\"sub-head\" colspan=\"2\">\n\nAdvanced\n\n</td></tr><tr><td class=\"sub-head\" colspan=\"2\">\n\nHide this node\n\n</td></tr><tr><td>\n\nConditionally use this node if\n\n</td><td>\n\nA 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.\n\n</td></tr></tbody>\n</table>## Example Topic Block utilities\n\nThe 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.\n\n\\[Omitted image \"topic-block-initial-props.png\"\\] Alt text: Example topic block.\n\nThe following Topic Block utility properties have the **Use dynamic Topic Block** toggle switch turned on.\n\n\\[Omitted image \"topic-block-dynamic.png\"\\] Alt text: Example topic block.\n\n## Using dynamic Topic Blocks\n\nToggling 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.\n\nFor 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.\n\nYou 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:\n\n-   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`.\n-   Define two input mappings: `password` and `twoFactorToken`, both set equal to an object passed in which contains their values.\n-   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.\n-   Define two output nodes to output success or failure, and an output to confirm to you whether the `tempPass` value is true.\n\n## Example dynamic Topic Block expression\n\n```\n(function execute() {\n    /* Return the name of the topic block to run. For example:\n        switch (vaVars.car_make) {\n            case 'Ford':\n                return 'Ford troubleshooting';\n            case 'Toyota':\n                return 'Toyota troubleshooting';\n            default:\n                return 'General car troubleshooting';\n        }\n    */\n})()\n```\n\nThe 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.\n\n**Parent Topic:**[Assistant Designer utilities](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/conversational-interfaces/virtual-agent/va-utilities.md)\n\n"}}