microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.48k stars 2.44k forks source link

Since move to v3 - sample code tutorial is incorrect #624

Closed chazwoza closed 8 years ago

chazwoza commented 8 years ago

See getting started page here: http://docs.botframework.com/en-us/node/builder/overview/#navtitle

Tutorial code doesn't work with emulator

chazwoza commented 8 years ago

Example code on NPM doesn't work either... uses deprecated bot builder: https://www.npmjs.com/package/botbuilder

Please can you provide working examples and/or updates because something is not right with this 3.0.0 release.

OR13 commented 8 years ago

@chazwoza You may find this example helpful:

http://docs.botframework.com/en-us/node/builder/guides/core-concepts/

OR13 commented 8 years ago

Using VSCode, ngrok, ChatConnector and WebChat, I'm able to debug this simple Node app:

var server = restify.createServer();

var connector = new builder.ChatConnector({
  appId: process.env.MICROSOFT_APP_ID,
  appPassword: process.env.MICROSOFT_APP_PASSWORD
});

var bot = new builder.UniversalBot(connector);

bot.dialog('/', function (session) {
  session.send("Hello World");
});

server.post('/api/messages', connector.listen());

server.listen('0.0.0.0', '3978', function () {
  console.log(server.url);
});

The server responds with 202 Accepted... However, session.send("Hello World"); fails to display on the WebChat.

I can see in the XHR requests for the WebChat that my initial message is properly added to the conversation, but the bots response (result of session.send) is not. There are no errors thrown or observed.

Can someone provide a working example which uses the ChatConnector WITH credentials?

chazwoza commented 8 years ago

I think I was wrong in this issue.. the real issue here is the emulator doesn't work.

rohit2912911 commented 8 years ago

getting same error with .net code also..

OR13 commented 8 years ago

The same exact code which produced 204 with no conversation messages added for WebChat and SMS works with Telegram.

Using ngrok, LetsEncrypt, VSCode, ChatConnector and Telegram, I am able to debug my bot, and I do receive responses in the Telegram client.

@Stevenic hopefully this helps. Maybe step through a response with (WebChat or SMS) and Telegram, there must be something wrong here, but I'm not able to see it.

Stevenic commented 8 years ago

@OR13 upgrade to v3.0.1 ad please let me know if you're still seeing issues.

OR13 commented 8 years ago

When debugging v3.0.1

process.env.MICROSOFT_APP_ID: <security>
process.env.MICROSOFT_APP_PASSWORD:  <security>

Launching Restify Server...
http://[::]:8080
ERROR: ChatConnector: receive - invalid token. Check bots app ID & Password.
ERROR: ChatConnector: receive - invalid token. Check bots app ID & Password.

Sample Telegram Log

...
Me: TEST
Bot: ACCEPTED
Me: TEST
Bot: ACCEPTED
Me: TEST
Bot: FORBIDDEN
Me: TEST
Bot: FORBIDDEN
Me: TEST
Bot: ACCEPTED
Me: WTF, are you alive?
Bot: FORBIDDEN
Me: >:(
Bot: ACCEPTED
Me: TEST
Bot: ACCEPTED
Me: TEST
...

It appears that some requests are getting rejected while others succeed.

I'm not changing Credentials, but I can't confirm that the sdk isn't somehow changing env variables or its references to them.

I read on some other issue there was conjecture that MS load balancers are responsible for this sort of thing, upstream of the sdk in some networking middlewear stew, or stews.

On dev.botframework.com, If I spam the Test button, I get FORBIDDEN and ACCEPTED in about the same ratio.

Networking error seems like root cause to me.

Thanks for your help! @Stevenic

muzahmed commented 8 years ago

@OR13 I tried my bot (nearly identical setup) and works via webchat -- are you still seeing issues?

muzahmed commented 8 years ago

@chazwoza were you able to get your bot up and running? that sample code (https://docs.botframework.com/en-us/node/builder/overview/#navtitle) worked for me, npm looks out of date.

Stevenic commented 8 years ago

Anyone having issues still?