https://discord.gg/botpress logo
Getting images from instagram
# 🤝help
v
I am using botpress autonomous node and reciving images from instagram Client sending multiple images from instagram how can i save them all in a array and what prompt i might should provide to autonomous node. Or any other way.
@User
Hey Guys i would love your comments on this please 🙂
While chatting with customers i am reciving images, Client can submit 3-4 images at once but how to save them all atonce
I was able to save 1 but multiple can't understand how
e
just as a possible initial hypothesis, I understand that when users send images, and we review the conversation, it looks like a link sent by meta, something like this: " (image) https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=............ " what you could do is that at the moment of detecting these links (images), it sends them by means of a string separated by commas to a flow. “https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid,https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid,https://lookaside.fbsbx.com/whatsapp_business/attachments/?” once in the flow, by means of code, you make the separation of the string with “,” and you save each links separately. -> I don't know how to save images.
v
Copy code
/** 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