Skip to content Skip to sidebar Skip to footer

Get Dialogflow Context Parameters From A Follow Up Intent In Python

I created a flask app in python to send text to Dialogflow in order to detect the intent and return the fulfillment text as response from it. Then I extended this to also return al

Solution 1:

I thing you could read the parameter ordernumber with get() function, something like this:

outCnt = query_result.get('outputContexts') 
outCnt = outCnt[2] 
# Second element of 'OutputContexts' in query_result (a Multidict) contains parameter 'ordernumber'
ordernumber = outCnt.get('parameters').get('ordernumber')

Solution 2:

It took me a minute to figure it out but the syntax is pretty much adding adding a "." to index the 'dictionary' vs the usual ['key'] and when a list using indices.

So to access fulfullment_message for example you would do:

response.query_result.fulfillment_messages[0].text.text[0]

So in your case (I don't know how to replicate the exact object but the starting point to get to parameters would be:

response.query_result.output_contexts[0].parameters

I would rate you just need a .ordernumber otherwise try using [0]... ['ordernumber'] etc. for your specific case and let me know too :)


Post a Comment for "Get Dialogflow Context Parameters From A Follow Up Intent In Python"