This tutorial shows the entity detection callback, and illustrates a common pattern for resolving entities.
This tutorial requires that the tutorialEntityDetectionCallback
bot is running.
npm run tutorial-entity-detection
Entity Detection callbacks enable modification of the entity recognition behavior and entity manipulation through code. We will demonstrate this functionality by walking through a typical entity detection callback design pattern. For example, resolving "the big apple" to "new york".
- In the Web UI, click "New Model."
- In the "Name" field, type "EntityDetectionCallback" and hit enter.
- Click the "Create" button.
Three entities are needed in this example, so let’s create the three.
- On the left panel, click "Entities", then the "New Entity" button.
- Select "Custom Trained" for the "Entity Type."
- Type "City" for the "Entity Name."
- Click the "Create" button.
- Click the "New Entity" button.
- Select "Programmatic" for the "Entity Type."
- Type "CityUnknown" for the "Entity Name."
- Click the "Create" button.
- Click the "New Entity" button.
- Select "Programmatic" for the "Entity Type."
- Type "CityResolved" for the "Entity Name."
- Click the "Create" button.
Now, create three actions.
- On the left panel, click "Actions", then the "New Action" button.
- In the "Bot's response..." field, type "Which city do you want?"
- In the "Expected Entity in User reply..." field, type "City."
- In the "Disqualifying Entities" field, type "City."
- Click the "Create" button.
- Click the "New Action" button.
- In the "Bot's response..." field, type "Which city do you want?"
- In the "Expected Entity in User reply..." field, type "I don't know this city."
- Click the "Create" button.
- Click the "New Action" button.
- In the "Bot's response..." field, type "$CityResolved is very nice."
- Click the "Create" button.
Here's the callback code:
- On the left panel, click "Train Dialogs", then the "New Train Dialog" button.
- In the chat panel, where it says "Type your message...", type in "hi"
- Click the "Score Actions" button.
- Select the response, "Which city do you want?"
- In the chat panel, where it says "Type your message...", type in "big apple"
- Click the "Score Actions" button.
- Clicking the button triggers the entity detection callback
- The callback code sets the CityResolved Entity value correctly to "new york"
- Select the response, "new york is very nice."
This pattern is typical of many bot scenarios. User utterances and extracted entities are supplied to your business logic, and that logic transforms the utterance into canonical form, which is then saved into programmatic entities, for subsequent turns of the dialog.
[!div class="nextstepaction"] Session callbacks