I have developed cloud functions and am using 'generic output' with image response types, as well as text. However when I search for a product (which uses my cloud function), the last result appears.
For example:
Me: Buy Classic now
Bot: Name: Classic, Price: 4.99, Description: Classic description
But when I search for another product
Me: Buy Extra now
the bot will display
Bot: Name: Classic, Price: 4.99, Description: Classic description
Only until another search instance does it refresh and display the correct result.
{
"context": {
"name": "",
"counter": 0
},
"output": {
"generic": [
{
"values": [
{
"text": "Found Products"
}
],
"response_type": "text",
"selection_policy": "sequential"
},
{
"title": "<? $result.body.items[0].name ?>",
"source": "http://**********/pub/media/catalog/product<? $result.body.items[0].custom_attributes[5].value ?>",
"description": "$<? $result.body.items[0].price ?>",
"response_type": "image"
},
{
"title": "Select one of the following options",
"options": [
{
"label": "Order a subscription",
"value": {
"input": {
"text": "Order a subscription"
}
}
},
{
"label": "More Details",
"value": {
"input": {
"text": "More Details"
}
}
}
],
"response_type": "option"
}
]
},
"actions": [
{
"name": "/**********@gmail.com_dev/getProducts2",
"type": "server",
"parameters": {
"url": "<?entities.products[0].literal?>"
},
"credentials": "$my_creds",
"result_variable": "context.result"
}
]
}