botbuilder-js/libraries/botbuilder-ai
Jhonatan Sandoval Velasco cd6cf6f9f8
bump: Update ESLint packages and migrate to eslint.config.cjs files (#4776)
* update eslint configurations

* show only eslint warnings

* add dependencies

* removed unused imports and add only warn to every library

* move eslint-plugin-only-warn to the right place

* fix import errors

* remove files config

* Update eslint.config

* Remove blank line and spaces

---------

Co-authored-by: Joel Mut <joel.mut@southworks.com>
Co-authored-by: CeciliaAvila <cecilia.avila@southworks.com>
2024-10-29 09:04:25 -05:00
..
etc fix: [#4470] Migrate off @azure/ms-rest-js botbuilder-ai (#4577) 2023-12-07 12:30:22 -06:00
schemas Add schemas from C# to packages. (#2986) 2020-10-30 18:02:49 -07:00
src bump: [#4684] Update multiple dependencies inside public libraries to latest version (#4739) 2024-09-10 08:51:24 -05:00
tests fix: [#4470] Migrate off @azure/ms-rest-js botbuilder-ai (#4577) 2023-12-07 12:30:22 -06:00
.gitignore updated project gitignore files 2018-08-13 17:17:16 -07:00
.nycrc Added code coverage analysis (#26) 2018-01-29 18:09:48 -08:00
LICENSE Add LICENCE to libraries (#4169) 2022-03-21 17:43:03 -04:00
README.md Updates a number of references to "main" (#2803) 2020-09-28 16:15:00 -07:00
api-extractor.json chore: add test:compat to CI tests (#3691) 2021-05-19 15:21:39 -07:00
eslint.config.cjs bump: Update ESLint packages and migrate to eslint.config.cjs files (#4776) 2024-10-29 09:04:25 -05:00
package.json bump: Update ESLint packages and migrate to eslint.config.cjs files (#4776) 2024-10-29 09:04:25 -05:00
tsconfig.json fix: QnAMakerDialog to handle interuption scenarios (#3346) 2021-03-02 11:05:18 +08:00

README.md

Bot Builder AI

Cognitive services extensions for Microsoft BotBuilder.

Installing

To add the latest version of this package to your bot:

npm install --save botbuilder-ai

Use the Daily Build

To get access to the daily builds of this library, configure npm to use the MyGet feed before installing.

npm config set registry https://botbuilder.myget.org/F/botbuilder-v4-js-daily/npm/

To reset the registry in order to get the latest published version, run:

npm config set registry https://registry.npmjs.org/

What's included?

This module contains interfaces for using Microsoft LUIS and Microsoft QnA Maker in your Botbuilder application.

Use

First, import the nessary functionality into your app.

const { LuisRecognizer, QnAMaker } = require('botbuilder-ai');

Configure and instantiate a LuisRecognizer. You will need to acquire values for appId, subscriptionKey and region from the LUIS website.

// Map the contents to the required format for `LuisRecognizer`.
const luisApplication = {
    applicationId: process.env.appId,
    endpointKey: process.env.subscriptionKey,
    azureRegion: process.env.region
}

// Create configuration for LuisRecognizer's runtime behavior.
const luisPredictionOptions = {
    includeAllIntents: true,
    log: true,
    staging: false
}

const luisRecognizer = new LuisRecognizer(luisApplication, luisPredictionOptions, true);

Now, call LUIS into action once you've got a TurnContext object:

// Listen for incoming requests.
server.post('/api/messages', (req, res) => {
    adapter.processActivity(req, res, async (turnContext) => {
        const results = await luisRecognizer.recognize(turnContext);

        // Since the LuisRecognizer was configured to include the raw results, get the `topScoringIntent` as specified by LUIS.
        const topIntent = results.luisResult.topScoringIntent;

        // Now, use topIntent to decide what action to take.
        switch (topIntent) {
            case '<some intent>':
            // ... 
            break;
        }

    });
});

Examples

See this module in action in these example apps: