I'm developing a messenger chatbot to sell clothes using node and a little of diagflow, but I'm stuck in the productcart, this is the problem: I'm using a generic template with a postback button "add item" and payload "additem_database", to add an item to my database, but I'm having difficulty finding a way to identify the item that I'm adding, when I click, the response is something like that :
{"object":"page","entry":[{"id":"596254160722097","time":1523729982009,
"messaging":[{"recipient":{"id":"596257560734097"},
"timestamp":1523729982009,
"sender":{"id":"16304620870031321"},
"postback":{"payload":"additem_database",
"title":"add item"}}]}]}
Received postback for user 1630462087003321 and
page 596257160724245 with payload 'additem_database' at 1523729982784
this only gives me the title of the button and the payload, the only solution that I thought was to name the button title with the same name of the product like this "add t-shirt", and then use the button title to find in my database and add to my cart, but this is not the best solution, so, my question is:
there is a way to get all the generic template data as a response when I click on the button, instead of only get the button data? or there is another type of data that I can use in the button response to use as an identifier?
Thank you if you had the time to read all.
The usual way to do this would be to append something like a product ID or SKU to the payload. So the payload for your postback button would be something like 'additem_database_09375029740295742'. Then you just parse the product ID from the string.