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

ERROR: Too many calls to session.endDialog()

Open heywoodg opened this issue 10 years ago • 3 comments

I am looking at the MS Botbuilder framework, and trying to get a fairly simple bot to answer questions that has been passed through LUIS.AI. In fact to start with, I took the multi-turn example and modified it.

So here is my app.js and I think the problem is something to do with the answer section:

function answerQuestion(field, answerTemplate) {
    return function (session, results) {
        // Check to see if we have a product. The user can cancel picking a product so IPromptResult.response
        // can be null. 
        if (results.response) {
            // Save product for multi-turn case and compose answer            
            var Product = session.dialogData.Product = results.response;
            var answer = { Product: Product.entity, value: data[Product.entity][field] };
            session.send(answerTemplate, answer);
        } else {
            session.send(prompts.cancel);
        }
    };
}

var data = {
  'gas': {
      StartDate: 'March 10th, 2016',
      NextInvoiceDate: 'June 13th, 2016',
      LastInvoiceDate: 'May 13th, 2016',
      LastAmount: '£23.56',
      NextAmount: '£26.32',
      description: 'You gas bill is based around the units of gas you have used in the past billing period, plus a standing charge. You next bill is an extrapolation if your current usage data for the period, and also based on your usage history.',
      website: 'http://www.mygas.foo'
  },
  'electricity': {
      StartDate: 'March 10th, 2016',
      NextInvoiceDate: 'June 13th, 2016',
      LastInvoiceDate: 'May 13th, 2016',
      LastAmount: '£27.35',
      NextAmount: '£29.72',
      description: 'You electricity bill is based around the units of gas you have used in the past billing period, plus a standing charge. You next bill is an extrapolation if your current usage data for the period, and also based on your usage history.',
      website: 'http://www.myelectric.foo'
  }
};

the prompt file is here.

The LUIS bit I am fine with, so if I ask LUIS "when did my gas contract start", it returns this.

{
  "query": "when did my gas contract start",
  "intents": [
    {
      "intent": "StartDate",
      "score": 0.9994442
    }
  ],
 "entities": [
    {
      "entity": "gas",
      "type": "ProductType",
      "startIndex": 12,
      "endIndex": 14,
      "score": 0.998134553
    }
  ]
}

but app.js returns the session.enddialog() error.

So I think the problem is being generated in the answerQuestion function, but not sure the best way to troubleshoot it, nor why it worked fine with the sample data provided, but not after I changed the script.

heywoodg avatar Jun 04 '16 14:06 heywoodg

Not sure on your issue, but that error seems to be the generic "something went wrong" error deep within the bot framework... I have had that error many times and it never turns out to be that particular reason. Since you are running nodejs, you can fire up any IDE of choice to debug it and take a look at the stack trace to find out where the error comes from. I am using Microsoft's VSCode IDE which allows me to debug my node code and catch a breakpoint on any global errors, then take a look at the stack trace.

xmark avatar Jun 05 '16 23:06 xmark

Thanks. I will try and develop something similar in c#.

heywoodg avatar Jun 08 '16 07:06 heywoodg

You dont need C#, you can debug in nodejs as well...

xmark avatar Jun 09 '16 03:06 xmark