Dialogflow - Turning on fulfillment returns a different intent even when the webhook does nothing

时间:2019-03-19 15:18:57

标签: dialogflow dialogflow-fulfillment

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
});

0 个答案:

没有答案