I am making a Chatbot which is using Google Hangout Chat currently, but will be ported on other chat platforms.
The chat code is handled on a Node.js backend and the Intent identification is done using DialogFlow's Nodejs API.
The Hangout Chat Response is as following:
{
thread: {
name: thread.name
},
text: 'The response in text',
cards:['List of cards to show data']
}
The data is working fine, but I am stuck at parsing the response I get from DialogFlow and deciding on the text
property of the response. There're two options to choose to send as the text
property. One is queryResult.fulfillmentText
which is just a string and easy to assign to the text
property, while another is queryResult.fulfillmentMessages
which is an array of objects containing the same text somewhere. This is what it looks like in my case:
"fulfillmentText": "We could find few matching products based on your query",
"fulfillmentMessages": [
{
"text": {
"text": [
"We could find few matching products based on your query"
]
}
},
{
"text": {
"text": [
"2nd text"
]
}
}
],
My question is what should I use between fulfillmentText
and fulfillmentMessages
? Also what are the differences between both of them. Why there're multiple texts/messages, given that Hangout Chat expects just one text response?
PS: I am using DialogFlow V2 API
Got this from the Dialogflow Docs
- fulfillmentText (String) Text to be pronounced to the user or shown on the screen.
- fulfillmentMessages (Object) Collection of rich messages to show the user.
So I should be using fulfillmentText
to be sent as the text
property of Hangout Chat response. fulfillmentMessages
is for the "Rich Messages" such as Cards which I am anyway generating from my database.