Skip to content

Latest commit

 

History

History

javascript_nodejs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

CorePlus Bot Template (Node.js)

Prerequisites

To run the bot

  1. Select Import new app.
  2. Click Choose App file (JSON format)...
  3. Import CoreplusLUIS.json file located in the cognitiveModels folder of the project. This file contains six intents: Greeting, ChitchatCancel, ChitchatHelp, ChitchatJoke, ChitchatProfanity and None.
  1. After creating the QnA Maker service, create a knowledge base using the CoreplusKB.tsv file located in the cognitiveModels folder of the project. Use this .tsv file to populate your KB. Then add the chit-chat files (CoreplusPC.tsv and qna_chitchat_friendly.tsv) using the Add file link located in the Settings tab. Train and publish your model, and obtain the values to connect your bot to the knowledge base.
  • Create the appsettings.json file in the javascript_nodejs/src folder with the missing values for your bot app, LUIS and QnA Maker services. You will need Cosmos DB keys only when deploying to Azure.

    {
      "microsoftAppId": "<YOUR_APP_ID>",
      "microsoftAppPassword": "<YOUR_APP_PASSWORD>",
      "appInsights": {
        "instrumentationKey": ""
      },
      "LUIS-en-US": {
        "appId": "<YOUR_APP_ID>",
        "authoringKey": "<YOUR_AUTHORING_KEY>",
        "subscriptionKey": "<YOUR_AUTHORING_KEY>",
        "endpoint": "https://your-region.api.cognitive.microsoft.com"
      },
      "QNA-en-US": {
        "kbId": "<YOUR_KNOWLEDGE_BASE_ID>",
        "subscriptionKey": "<YOUR_SUBSCRIPTION_KEY>",
        "endpointKey": "<YOUR_ENDPOINT_KEY>",
        "hostname": "https://your-qnamaker-app-name.azurewebsites.net/qnamaker"
      },
      "cosmosDb": {
        "cosmosDbEndpoint": "https://your-cosmosdb-account-name.documents.azure.com:443/",
        "authKey": "<YOUR_AUTHORING_KEY>",
        "databaseId": "<YOUR_DATABASE_ID>",
        "containerId": "<YOUR_COLLECTION_ID>"
      },
      "publicResourcesUrl": "http://localhost:3978",
      "allowPublicFolder": "true"
    }
  • Navigate to the javascript_nodejs folder and run the following npm commands to install modules and start the bot:

    npm install
    npm start

Testing the bot using Bot Framework Emulator v4

Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework Emulator version 4.5.0 or greater from here

Connect to the bot using Bot Framework Emulator v4

  • Launch Bot Framework Emulator
  • File -> Open Bot
  • Enter a Bot URL of http://localhost:3978/api/messages, <YOUR_APP_ID> and <YOUR_APP_PASSWORD>.

Further reading