botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Since move to v3 - sample code tutorial is incorrect

Open chazwoza opened this issue 10 years ago • 11 comments

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

Tutorial code doesn't work with emulator

chazwoza avatar Jul 09 '16 11:07 chazwoza

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.

chazwoza avatar Jul 09 '16 11:07 chazwoza

@chazwoza You may find this example helpful:

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

OR13 avatar Jul 09 '16 15:07 OR13

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?

OR13 avatar Jul 09 '16 18:07 OR13

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

chazwoza avatar Jul 10 '16 02:07 chazwoza

getting same error with .net code also..

rohit2912911 avatar Jul 11 '16 05:07 rohit2912911

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.

OR13 avatar Jul 12 '16 00:07 OR13

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

Stevenic avatar Jul 12 '16 01:07 Stevenic

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

OR13 avatar Jul 13 '16 01:07 OR13

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

muzahmed avatar Aug 02 '16 16:08 muzahmed

@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.

muzahmed avatar Aug 02 '16 16:08 muzahmed

Anyone having issues still?

Stevenic avatar Aug 04 '16 06:08 Stevenic