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");
});
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.
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.
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.
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.
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:
In V3, to reflect changes to the underlying auth model, these keys have been changed to:
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
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With