Share via


Debug and validate language generation and understanding files

APPLIES TO: Composer v1.x and v2.x

This article introduces the validation functionality provided in Bot Framework Composer. The validation functionality helps you identify syntax errors and provide suggested fixes when you author .lg files, .lu files, and expressions during the process of developing a bot using Composer. With the help of the validation functionality, your bot-authoring experience will be improved and you can easily build a functional bot that can run correctly.

Prerequisites

Diagnostics

When there are errors in Composer, the button to start the bot will be disabled.

Error icon

Selecting the error or warning icon will navigate you to the Problems pane at the bottom of Composer where you can view a full list of the errors and warnings.

Problems pane

Selecting the Errors and Warnings buttons will hide or display your bot's error and warning messages.

Starting in version 2.0 of Composer, there's also an Output pane that shows the standard output/error stream, when the bot is running, from the .NET or JavaScript runtime. This includes start up information and runtime errors.

For information about how to use the Web Chat Inspector and the Watch panel, see the article about testing and debugging bots with Web Chat.

.lg files

When an .lg file has syntax errors, the Bot responses code editor displays a red wavy line under the error. While you have template errors, you can't switch to the response editor without losing your current response template.

LG code editor error

In the example .lg template above, abc is invalid. Do the following to diagnose and fix the error:

  1. Read the error message beneath the editor and click Refer to the syntax documentation here to refer to the syntax documentation.

  2. Hover your mouse over the erroneous part and read the detailed error message with suggested fixes.

    Hover LG error

    Note

    If you don't find the error message helpful, read the .lg file format article and use the correct syntax to compose the language generation template.

Select Bot Responses from the Composer menu, then select Show code. You'll find the error is also saved and updated here, as shown below:

Bot Responses

  • The tiny red rectangle on the right end of the editor helps you to identify where the error is. This is especially helpful when you have a long list of templates.
  • The error message at the bottom of the editor indicates the line numbers of the error. In this example, line5:0 - line5:3 means the error locates in the fifth line of the editor from the first character (indexed 0 )to the fourth character (indexed 3).

Hover your mouse over the erroneous part. You'll see the detailed error message with suggested fixes.

Hover LG bot responses

In this example, the error message indicates a - is missing in the template. After you add the - sign in the lg template, you'll see the error message disappear.

If you go back to the code editor, you'll see the change is updated and error disappear as well. You'll also be able to switch back to the response editor.

Warning

Switching from the code editor to the response editor will delete any templates that aren't activity response templates. Be cautious when switching between the two editors.

.lu files

When you create an Intent recognized trigger and your .lu file has syntax errors, a red wavy line will show under the error in the Trigger phrases, and the border of the box will appear red.

LU inline error

Do the following to diagnose and fix the error:

  1. Selecting the Refer to the syntax documentation here link in the error will open the .lu file format article.

  2. Hover your mouse over the erroneous part and read the detailed error message with suggested fixes.

    Hover LU error

    Note

    If you don't find the error message helpful, read the .lu file format article and use the correct syntax to compose the language understanding template.

Expressions

When you send a response with an invalid expression, a warning will appear at the top right of Composer. If you're in the code editor view, you'll see a red wavy line underneath the erroneous expression. The box around the expression will appear yellow, as seen below.

Expression send a response warning

To diagnose and fix the error, read the error message and select Refer to the syntax documentation here to be taken to the syntax documentation. For more information see Adaptive expressions syntax.

Once the expression warning is fixed, the red wavy line under the expression will disappear, and the border around the editor will appear black.

Custom functions

For users who have custom functions defined in a custom runtime, additional configuration is required in the customFunctions field of the Bot Settings page. If you don't have the customFunctions setting configured properly, Composer will identify custom functions as errors, and the Start Bot button (or the Restart Bot button) will be disabled.

To configure the customFunctions setting:

  1. Select Project Settings from the Composer menu then toggle Advanced Settings View (json).

  2. In the customFunctions field, add the names of the custom functions. For example:

    "customFunctions": [
        "AskBot.stripTags"
    ]
    

    Tip

    You can set the customFunctions field to functionPrefix.* to support validation of custom functions with a specific prefix, for example AskBot.*.