botframework

Getting started with botframework

Remarks#

Microsoft Bot Framework is a comprehensive offering to build and deploy high quality bots for your users to enjoy in their favorite conversation experiences. Developers writing bots all face the same problems: bots require basic I/O; they must have language and dialog skills; they must be performant, responsive and scalable; and they must connect to users – ideally in any conversation experience and language the user chooses. Bot Framework provides just what you need to build, connect, manage and publish intelligent bots that interact naturally wherever your users are talking – from text/sms to Skype, Slack, Facebook Messenger, Kik, Office 365 mail and other popular services.

Bots (or conversation agents) are rapidly becoming an integral part of one’s digital experience – they are as vital a way for users to interact with a service or application as is a web site or a mobile experience. Developers writing bots all face the same problems: bots require basic I/O; they must have language and dialog skills; and they must connect to users – preferably in any conversation experience and language the user chooses. The Bot Framework provides tools to easily solve these problems and more for developers e.g., automatic translation to more than 30 languages, user and conversation state management, debugging tools, an embeddable web chat control and a way for users to discover, try, and add bots to the conversation experiences they love.

The Bot Framework consists of a number of components including the Bot Builder SDK, Developer Portal and the Bot Directory.

enter image description here

Versions#

Bot Builder Latest Releases

LanguageVersionRelease Date
Node.js3.7.02017-02-23
C#3.5.52017-03-07

Previous releases can be found here.

Installation or Setup


C#

  1. Visual Studio 2015 (latest update) - you can download the community version here for free: www.VisualStudio.com

  2. Important: update all VS extensions to their latest versions Tools->Extensions and Updates->Updates

  3. Download the Bot Application template from here: Template Download Save the zip file to your Visual Studio 2015 templates directory which is traditionally in “%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C#” Note: you will need to restart visual studio after this step, in order to use the template.

New Bot Application Project

  1. Create a new C# project using the new Bot Application template

Bot Application Solution

Once your bot is finished being created, you should have a solution similar to this:

Bot Application Browser Window

  1. Run the application by hitting F5, or by clicking the green Run button in the tool bar. Since our new bot is actually a WebAPI project, a browser window will be opened to the default.htm page. The bot is now running, and exposed locally. Note the url … it will be needed to setup the Bot Framework Emulator in the next step.

Node.js

  1. Create a new node.js project by using npm init.

  2. Install the botbuilder sdk and restify using the following npm commands:

    npm install —save botbuilder npm install —save restify

  3. To create your bot, create a new file called index.js, and copy the following code to initialize the bot.

    var restify = require(‘restify’); var builder = require(‘botbuilder’);

    // Setup Restify Server var server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978, function () { console.log(‘%s listening to %s’, server.name, server.url); });

    // Create chat connector for communicating with the Bot Framework Service var connector = new builder.ChatConnector({ appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD });

    var bot = new builder.UniversalBot(connector);

  4. You should now be able to run this file using node index.js.

This is a basic setup that will be required for all bots created with bot framework. You can treat this as a blank template project to start with. It initializes a restify server for your bot and creates a connector to connect local machines with your server.

Downloading Emulator for Debugging (Both for node and C#)

Emulator Image

  1. Download and install the Bot Framework Emulator Emulator Download

  2. Run the emulator, and enter the url from step 5 (C#) into the Endpoint URL text box. Then, click “Connect”.

Connecting to Bot

  1. You should now be able to communicate with your bot using the chat window in the emulator. You will see the conversation details logged in the bottom right, and you can click on the Post and Get line items to see the json that has been passed back and forth.

enter image description here

Congratulations on creating a Bot using the Microsoft Bot Framework!


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow