victorious-dress-99881
05/09/2025, 2:40 PMvictorious-dress-99881
05/09/2025, 2:41 PMvictorious-dress-99881
05/09/2025, 2:41 PMvictorious-dress-99881
05/09/2025, 2:47 PMvictorious-dress-99881
05/09/2025, 2:47 PMechoing-notebook-80704
05/09/2025, 4:38 PMvictorious-dress-99881
05/13/2025, 10:58 PM/** 1. make sure the array & flag exist */
workflow.imageList = workflow.imageList || []
/** 2. helper to push only new URLs */
const add = (u) => {
if (u && !workflow.imageList.includes(u)) workflow.imageList.push(u)
}
/** 3. what did Instagram send? ---------------------------------- */
// A) normal 1-photo DM → event.type === 'image'
if (event.type === 'image' && event.payload?.imageUrl) {
add(event.payload.imageUrl)
}
/* B) multi-photo DM (Instagram bundles them as one “bloc”)
each sub-item lives in event.payload.items[] */
if (event.type === 'bloc' && Array.isArray(event.payload.items)) {
for (const itm of event.payload.items) {
if (itm.type === 'image' && itm.payload?.imageUrl) {
add(itm.payload.imageUrl)
}
}
}
/* C) ultra-rare fallback - some Meta payloads expose a “payload.url” */
if (event.payload?.payload?.url) add(event.payload.payload.url)
/** 5. (optional) log to Botpress console while testing */
console.log('Current images:', workflow.imageList)
Hey Guys I am able to solve this issue i am sure in future alot gonna ask same use this above