Reputation: 11
I am building an Android Application where i am passing the request from the app to Dialogflow. Dialog flow then passes it to a Node.js script and query a database for result and finally send the response to the Android device. Now the query results are stored inside "payload" of "messages". However I am unable o access the payload part. I mean I can access "messages" with getMessages but I cannot probe further into messages. The response from Dialogflow is as below and i want to access the elements tag in the below JSON. How can I do it? Thanks
RESPONSE RECEIVED IN ANDROID from Dialogflow.
{
"lang": "en",
"result": {
"source": "agent",
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"speech": ""
},
{
"type": 4,
"payload": {
"template_type": "list",
"elements": [
{
"NAME": "francis electrician",
"CONTACT": "98199 66928",
"ADDRESS": "sundar nagar, santacruz east, mumbai, maharashtra, india",
"AREA": "santacruz"
},
{
"NAME": "raj electrician\n",
"CONTACT": " 98205 45064",
"ADDRESS": "jdb seva sangh, gazdhar bandh sb patil road, govind nagar, santacruz west,, mumbai, maharashtra 400054, india",
"AREA": "santacruz"
}
]
}
}
]
},
"score": 1
},
"status": {
"code": 200,
"errorType": "success"
}
}
Upvotes: 0
Views: 110
Reputation: 5256
You may use Android Dialogflow SDK. This may help you in building Android app integrated with Dialogflow. It will do the parsing on its own and give you objects to play with. Check out the documentation on their Github page for details.
Upvotes: 1