Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to expose LUIS entities for use in questions #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

menachem-stratfs
Copy link

With the release of Botkit 4.8, bot developers now have access to the full message object inside of dialogs. This allows for the opportunity to use LUIS entities not just to trigger new dialogs, but also as a means of interpreting a user's response to a prompt.

For example:

    dialog.addQuestion('Enter a date', async (rawInput, convo, bot, message) => {
        const dateEntity = message.entities.find(entity => entity.type === 'builtin.datetimeV2.date');
        const date = new Date(dateEntity.resolution.value);
        doStuffWith(date);
        ...
}

The PR exposes an option alwaysIncludeEntities that, when true, will attach entities from the LUIS service to the message.

I've also added a helper function that finds an expected entity type. It can be used like this:

    dialog.addQuestion('Please enter the price', async (rawValue, convo, bot, message) => {
        const number = luis.middleware.getEntity(message, 'builtin.number', 'builtin.currency') || rawValue;
        doStuffWith(number);
        ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant