Search code examples
botframework

How can i implement bot framework in my visual studio code?


how can i implement bot framework in my visual studio code ,And what packages are need to be installed for the usage of bot framework in visual studio code?


Solution

  • This is a pretty broad question, but I'll try to cover all of the bases bases and include answers for Node/JS/TS as well as C#.

    Create a Bot

    You have 4 options:

    1. Create the bot in Azure:

      1. In the Azure Portal, Create a resource > Web App Bot > Go through steps and create. enter image description here
      2. Open the "Web App Bot" resource you just created > Build > Download Bot Source Code. enter image description here
    2. [JS/TS/Node ONLY] Create the bot via Yeoman: (See JavaScript Quickstart below)

      1. npm install -g yo generator-botbuilder
      2. yo botbuilder.
      3. Follow the steps and generate your bot.
    3. [C# ONLY]: Use a VSIX template in Visual Studio:**

      1. Download the BotBuilder V4 VSIX template
      2. Create a new Project in Visual Studio (you can get more details about each bot template in the link above) enter image description here
    4. Clone a Sample:

      1. Clone one of these samples
        • I recommend Basic Bot: JS/Node / C#, for something somewhat complex and Simple Prompt: JS/Node / C#, for something easier
      2. Follow each sample's REAMDE.md for further instruction.
    5. Create it from scratch as @TobiasC mentioned. I highly recommend against going this route unless you know what you're doing. It is much easier to start with a sample. Using Yeoman to generate an Empty Bot is a good route to go if you want something pretty bare bones.

    Packages

    The required packages really varies depending on what you're going to do with your bot.

    JS/TS/Node: Here's a snippet of Basic Bot's package.json, showing all the packages it uses:

    "dependencies": {
        "botbuilder": "^4.2.0",
        "botbuilder-ai": "^4.2.0",
        "botbuilder-dialogs": "^4.2.0",
        "botframework-config": "^4.2.0",
        "dotenv": "^6.1.0",
        "restify": "^7.2.3"
    },
    "devDependencies": {
        "eslint": "^5.9.0",
        "eslint-config-standard": "^12.0.0",
        "eslint-plugin-import": "^2.14.0",
        "eslint-plugin-node": "^8.0.0",
        "eslint-plugin-promise": "^4.0.1",
        "eslint-plugin-standard": "^4.0.0",
        "nodemon": "^1.18.6"
    }
    

    C# Here's a list of NuGet packages for Basic Bot from the .csproj file:

    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
    <PackageReference Include="Microsoft.Azure.CognitiveServices.ContentModerator" Version="0.12.1-preview" />
    <PackageReference Include="Microsoft.Azure.CognitiveServices.Language" Version="1.0.1-preview" />
    <PackageReference Include="Microsoft.Bot.Builder" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Configuration" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Connector" Version="4.2.2" />
    <PackageReference Include="Microsoft.Bot.Schema" Version="4.2.2" />
    <PackageReference Include="Microsoft.Graph" Version="1.10.0" />
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008">
    

    Run the Bot

    Run npm start from within the bot's directory (Node/JS/TS) or press F5 in Visual Studio (C#). By default, the bot will listen for messages at http://localhost:3978

    Testing and Debugging

    Use the BotFramework Emulator for local testing. See "Botframework Emulator - Getting Started" below.

    General

    Really, I recommend following the docs and samples as much as possible and using the SDK Reference, when necessary. Links below.

    References

    JavaScript Quickstart

    C# Quickstart

    Debug a Bot

    Botframework Emulator - Getting Started

    The Docs

    TS SDK Reference

    C# SDK Reference