Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bot framework v3 unauthorized

Tags:

botframework

I'm trying to use MS botframework V3 to create a basic bot using the nodejs tutorial code, but I keep getting 401 Unauthorized using the emulator. Please help?

AppId / Secret are set in env variables and definitely correct in emulator.

Code below

var restify = require('restify');
var builder = require('botbuilder');

//=========================================================
// Bot Setup
//=========================================================

// 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 bot
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

//=========================================================
// Bots Dialogs
//=========================================================

bot.dialog('/', function (session) {
    session.send("Hello World");
});
like image 500
C. Woza Avatar asked Jul 09 '16 06:07

C. Woza


People also ask

What is bot framework service?

Microsoft Bot Framework and Azure Bot Service are a collection of libraries, tools, and services that let you build, test, deploy, and manage intelligent bots. The Bot Framework includes a modular and extensible SDK for building bots and connecting to AI services.

How do I find my Microsoft App ID and password for a bot?

To get your app or tenant ID To get your bot's app or tenant ID: Go to the Azure Bot resource blade for your bot. Go to the bot's Configuration blade. From this blade, you can copy the bot's Microsoft App ID or App Tenant ID.

What is bot Framework emulator?

Bot Framework Emulator is a desktop application that allows bot developers to test and debug bots, either locally or remotely. Using the Emulator, you can chat with your bot and inspect the messages that your bot sends and receives.

What is new bot framework?

Bot Framework CLI tools added lg as a core plugin and included other overall tool improvements. Updated the README files in the samples and added new Teams Typescript samples. Composer improved support for skills and improved integration for Cognitive Services. Web Chat added many accessibility improvements.


2 Answers

try changing the appId and appSecret to MicrosoftAppId and MicrosoftAppPassword respectively

As stated on botframework website

In V1, the authentication properties were stored with these keys:

  • AppId
  • AppSecret

In V3, to reflect changes to the underlying auth model, these keys have been changed to:

  • MicrosoftAppId
  • MicrosoftAppPassword

Edit: So, from a post on github by Steven the actual values are

  • appId

  • appPassword

    These values won't work with the emulator due to an issue with node sdk however they should work when deployed.

Link: https://github.com/Microsoft/BotBuilder/issues/625

like image 162
xanish Avatar answered Sep 28 '22 18:09

xanish


While using the emulator for the first time, i was giving an appid and password on my own. I learnt that no app id and no password also works fine in local.

:Removing the appid and password in the web.config in the bot application and in the emulator resolved my error. Hope it helps. Cheers!

like image 27
Bhadri narayanan Avatar answered Sep 28 '22 16:09

Bhadri narayanan