GithubHelp home page GithubHelp logo

Comments (25)

Stevenic avatar Stevenic commented on May 18, 2024

You should be able to call session.send() multiple times but to be honest the TextBot is currently the most tested path as that's what the Unit Tests use. Would it be possible for you to share the code with your waterfalls? Feel free to replace the business logic with a comment like "// doing something here". I just want to see how your dialogs hang together and I'll see if I can replicate the issues you're seeing. If I can replicate it I can fix it :)

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

And by the way... calling session.endDialog() from any step in the waterfall should be fine. That was how I intended things to work.

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

Oh... one other question. Which version of the npm module are you using? Make sure you're at least running 0.6.1 as we did push a fix yesterday that updates the URL we send out of band messages to for BotConnectorBot (your secondary message.) The latest version is 0.6.2 and I'm about to have to push a 0.6.3

from botframework-sdk.

tomlm avatar tomlm commented on May 18, 2024

Make sure your botdata doesn't have old data from previous bots...As people change their schema they aren't clearing out the old data. Since the emulator never persists the bot data devs aren't running into this on their box, but only when they publish it into a place where they had an older bot with older bot data.

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Thx for all the responses!
I will get back to you @Stevenic!

@tomlm - where should the botdata be stored and how can I clear it?

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

@Aleksion BotBuilder hides all of this from you. It does a basic sanity check over the BotData that's coming in and if it thinks you've made radical changes to things it will clear it for you but Tom is correct there are a couple of edge cases where you could be getting something in with bad data. I don't think that's the case based on what you've described but if you want to make sure. Temporarily modify your bot to have a single root '/' dialog that does the following:

bot.add('/', function (session) {
    session.endDialog();
});

This will ensure that everything is reset.

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Hi @Stevenic - here's my waterfall code. It's a bit hacky - my goal was to try to get a functional bot as soon as possible :) I've removed some of the code for clarity (mainly in the requests)

  • I was running version 0.6.2 at the time. I'll try to update it to the latest now.
  • I've tried "wiping" the bot as suggested. But it seems it DOES cache previous results even after the "wipe"
[
  session => {
    builder.Prompts.text(session, 'What is the name of the company you want to search for?')
  },
  (session, results) => {
    session.userData.companyName = results.response;

    request(REQUEST_OBJECT, (error, response, body) => {
      if (!error && response.statusCode == 200) {
        session.userData.company = JSON.parse(body);
        session.send(`The first company I found was ${session.userData.company.name}`);

        builder.Prompts.choice(session, "Do you want me to fetch their accounts?", "Yes|No");
      } else {
        session.send("I'm sorry - couldn't find anything :(");
        session.endDialog();
      }
    })
  },
  (session, results) => {
    if (results.response && results.response.entity === "Yes") {
      request(SECOND_REQUEST_OBJECT, (error, response, body) => {
        if (!error && response.statusCode == 200) {
            var parsedResponse = JSON.parse(body);

            session.send(`You can find the latest accounts published on ${parsedResponse.url}`);
            session.endDialog();
          }else {
            session.send(`I couldn't find any documents for ${session.userData.company.name}`);
            sesison.endDialog();
          }


        } else {
          session.send("I'm sorry - couldn't find anything :(");
          session.endDialog();

        }
      })
    } else {
      session.send("Glad to be of service!");
      session.endDialog();
    }
  }
]

I wonder if it's my async calls that messes things up? (though it does work flawlessly with the TextBot

Let me know if you need any clarification

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

@Aleksion Lets break this into pieces. First you're definitely running into issues with sending back-to-back messages. We haven't tested that very thoroughly so I'll have to look into what's happening. We may have to introduce a small delay between messages to keep the switch from getting confused. For now I'd merge your send statement into your prompt so.

builder.Prompts.confirm(`The first company I found was ${session.userData.company.name}. Do you want me to fetch their accounts?`);

I also switched to using Prompts.confirm() which had a bug that I fixed in the latest build. This should address that issue.

The second issue you're seeing is that it's dumping straight into the waterfall when you say "Hi!". My question there is are you using a CommandDialog or something? What are you passing your waterfall to? I'd need to see that code.

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

When I wrote the code, confirm didn't work as you just mentioned. I'd much rather use that one, so thank you for the fix!

I'm using a CommandDialog as such:

new builder.CommandDialog()
  .matches('^cvr', builder.DialogAction.beginDialog('/cvr'))
  .onDefault(session => {
    if (session.userData.company) {
      session.send('This is the company you last searched for: %s, with VAT: %s ', session.userData.company.name, session.userData.company.vat);
      //session.send('With the VAT:', session.userData.company.vat);
    } else  {
      session.send('If you want to start a search, type: cvr');
    }
  })

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Add the message did as expected fix the first issue. I'll stick to that until #44 is fixed

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

Definitely acts like its bypassing the CommandDialog and going straight to the '/cvr' dialog. So from this I'm assuming CommandDialog is added as the root dialog '/' and then you have your waterfall added as '/cvr'. Also you didn't change the default right?

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

So this is going to sound crazy but it looks like ^cvr is matching when you say 'Hi!' could you replace the beginDialog action with:

session => { session.send('I heard: ' + session.message.text); }

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Yep - the command dialog is added at the root.

I've broken the application up a bit. I'll add the structuring code for clarity:

registerDialogs.js:
var cvrDialog = require('./cvr');
var indexDialog = require('./');

module.exports = function registerDialogs(bot) {
  bot.add('/', indexDialog);
  bot.add('/cvr', cvrDialog);
}
index.js

var builder = require('botbuilder');
var cvr = require('./cvr');

module.exports = new builder.CommandDialog()
  .matches('^cvr', builder.DialogAction.beginDialog('/cvr'))
  .onDefault(session => {
    if (session.userData.company) {
      session.send('This is the company you last searched for: %s, with VAT: %s ', session.userData.company.name, session.userData.company.vat);
      //session.send('With the VAT:', session.userData.company.vat);
    } else  {
      session.send('If you want to start a search, type: cvr');
    }
  })

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

my suspicion is we're getting something like cvrbot: Hi!

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Nope - it acts as suspected:
screen shot 2016-04-01 at 12 23 21

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

I've narrowed down the problem. It seems like it never returns to the root after beginning the dialog. (I removed the else statement in the onDefault to simplify things)

screen shot 2016-04-03 at 19 29 13

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

Now the dots are connecting for me...

Yes... We definitely have a problem with back-to-back calls to the server. This may not make a lot of sense but when you're calling session.send() followed by session.endDialog() we're triggering 2 calls to the server. One to send the message and a second to say that the dialog has ended. For now here's the fix...

When you want to end your dialog call:

session.endDialog({ response: 'message to send user' });

Then on the CommandDialog side do this:

.matches('^cvr', (session, results) => {
    if (results && results.response) {
        session.send(results.response);
    } else {
        session.beginDialog('/cvr');
    }
}) 

This should resolve your issue for now because it lets the send() persist the fact that the dialog has ended. I'm going to update the DialogActions.beginDialog() call to support the same basic behavior. You can end the dialog with a message to send to the user.

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Sounds like an event driven architecture for your backend would make sense - so you ensure that the final state is always a result of the events, in the order that they were received.

And then the botbuilder framework would also need to be implemented as such, so that a race condition between session.send() and session.endDialog() can't occur.

Thx for responding so swiftly @Stevenic ! Do you guys ever take the weekend off? ;) (you can close it unless you want to track more with this issue)

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

Just pushed and confirmed. That did fix the issue.

from botframework-sdk.

tvmick avatar tvmick commented on May 18, 2024

I've been trying to unsubscribe from this thread and indeed this site for over a wk , GitHub not answering my pleading for info to unsubscribe and the people on this thread are using it like an old CB radio and talking all night stopping me from sleeping and at 76 yrs old it's not Good , would you like your grandad kept awake all night and I derntswitch mobile of it my only life line

from botframework-sdk.

Aleksion avatar Aleksion commented on May 18, 2024

@tvmick - unwatch the repository?

And repositories like this will have "chatter all night", since it's being used globally.

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

@tvmick yes - you should unwatch. This is a new library so we have a lot of issues we need to work through. We're not trying to spam you but at the same time we're committed to helping our users solve their problems. Sorry.

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

@Aleksion I just checked in a change that will be in the next release which lets you send a message as part of calling endDialog(). This should let you go back to using the DialogActions.beginDialog() as you were. I'm not going to push the change to NPM yet as there's a valid work around and I'd like to accumulate some more changes.

from botframework-sdk.

Stevenic avatar Stevenic commented on May 18, 2024

I just published 0.7.0 which adds the ability to send a message when calling endDialog()

from botframework-sdk.

mikkhait avatar mikkhait commented on May 18, 2024

Sort of related to the same topic. I'm using 0.8.0 and trying to use session.send() site-by-side...

session.send("hey, good to see you here");
session.send("let's begin");

while this works in TextBot(), when using with BotConnector() session ends upon first session.send()

P.S. I'm using minSendDelay: 2 to slow things down a bit :)

from botframework-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.