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.
If I type 'no' -> 'no' -> 'no' -> 'yes'
The order of the triggered intents will be:
If I type the same exact utterances in the same order,
The order of the triggered intents will be:
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
});