0

I'm trying to understand how Dialogflow evaluates contexts. In the middle of a session where there are multiple active contexts and the user inputs an utterance that has a direct match with two or more intents that use these active contexts, what determines which intent will be triggered? (provided that the confidence levels are the same)

Additionally, does turning on fulfillment change how contexts are prioritized? If not, why does turning on fulfillment change a response when the web-hook does nothing?

Here's an example of the problem I'm encountering.

I have two almost identical flows:

Each sub-intent is triggered by either 'yes' or 'no' and all output contexts are set to have a lifetime of 5 turns. Both are identical in all aspects except that Flow2 has fulfillment turned on for all intents and Flow1 has them all turned off.

Flow 1

If I type 'no' -> 'no' -> 'no' -> 'yes'

The order of the triggered intents will be:

  1. ContextTest.no1
  2. ContextTest.no1.no2
  3. ContextTest.no1.no2.no3
  4. ContextTest.no1.no2.yes3

Flow 2

If I type the same exact utterances in the same order,

The order of the triggered intents will be:

  1. ContextTestFF.no1
  2. ContextTestFF.no1.no2
  3. ContextTestFF.no1.no2.no3
  4. ContextTestFF.yes1

Why does Flow 1 transition from no3 to yes3 while Flow 2 transitions back to yes1?

Here's the web-hook code. As you can see, the request is just being echoed and nothing is changing.

'use strict'

const Functions = require('firebase-functions')

exports.dialogflowFirebaseFulfillment = Functions.https.onRequest((request, response) => {
    console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
    console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
    let text = request.body.queryResult.fulfillmentText
    let responseToUser = {
        "source": "NeuraFlash",
        "fulfillmentMessages": [{
            "text": {
                "text": [text]
            }
        }],
        "fulfillmentText": [text]
    }

    responseToUser.outputContexts = request.body.queryResult.outputContexts
    console.log('Response: ' + JSON.stringify(responseToUser))
    response.json(responseToUser)

    return response
});
Community
  • 1
  • 1
yun
  • 1
  • 4
  • 1
    You say the webhook "does nothing". Can you show the code of the webhook? – Prisoner Mar 19 '19 at 17:01
  • 1
    one suggestion apart from the problem you are having : in your case, i feel you should set output context to zero when an intent is matched, so that there is less chance of ambiguity. – sid8491 Mar 20 '19 at 08:16
  • @Prisoner I edited the question to include the webhook code. As you can see, outputContexts is being directly copied so nothing should be changing. – yun Mar 20 '19 at 20:09
  • @sid8491 Yeah I've tried that and it seems to be a good solution when flows are small but it doesn't scale well making the more complex flows difficult to manage. – yun Mar 20 '19 at 20:36

0 Answers0