Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const productQuickreplies = (products, sliceSet, beginSlice, endSlice) => {
- // slice the elements of the array to the desired set size
- let slicedProducts = products.slice(beginSlice, endSlice);
- // form an array of quick replies with title and payload
- let quickReplies = slicedProducts.map(product => {
- return {
- "content_type": "text",
- "title": product.title,
- "payload": product.title
- };
- });
- // Check if the current set is not the last one
- if (endSlice < products.length) {
- // add an extra quick reply that will display the next set
- quickReplies.push({
- "content_type": "text",
- "title": "Next",
- "payload": `next_${beginSlice + sliceSet}_${endSlice + sliceSet}`
- });
- }
- return quickReplies;
- }
Add Comment
Please, Sign In to add comment