I’m wondering what the best way is to achieve the following: My user searches for a product, then I return a list of buttons that represent products. Now the customer selects a product by clicking on the respective button. Now I add the product to his cart.
In the past, for this I defined an entity “product” and an intent “selected_products” and then created a story like this:
## user adds items to cart
* agent.add_cart_items{"item": "Yoghurt"}
- action_search_items . # This presents user some products as buttons
* user.selected_products{"products": "123"}
- action_add_cart_items
With a button looking like this:
{
"title": product["name"],
"image_url": product["imageUrl"],
"buttons": [
{
"type": "postback",
"title": "Add",
"payload": '/user.selected_products{{"products": ["{product_id}"]}}'.format(product_id=product['id']),
},
]
}
Which worked fine. However, I don’t really like having a “product” entity just for passing the product IDs. Is there a way to e.g. use an inform intent? Something like this:
## user adds items to cart
* agent.add_cart_items{"item": "Yoghurt"}
- action_search_items . # This presents user some products as buttons
* inform # Not using entities here
- action_add_cart_items # Pick message value as product id
With a button like this:
{
"title": product["name"],
"image_url": product["imageUrl"],
"buttons": [
{
"type": "postback",
"title": "Add",
"payload": '/inform:123',
},
]
}
So sending a message while specifying the intent at the same time? Or is specifying the product entity the best way to go?