https://discord.gg/botpress logo
Send Whatsapp images to Botpress
# 🤝help
p
Hi there! I need to capture images sent by users on WhatsApp then pass it to Vision agent. I've integrated my Botpress with WhatsApp through oAuth config. Created a permanent access token in "system users" section of FB business account and assigned my WhatsApp account asset to it. Stored the generated token in Botpress as a variable. Used the code below in "Execute" card to retrieve the image data: const whatsappAccessToken = env.WHATSAPP_ACCESS_TOKEN const res = await axios.get(event.payload.imageUrl, { headers: { Authorization:
Bearer ${whatsappAccessToken}
, }, responseType: 'arraybuffer' }) const rawFileContent = res.data const mimeType = res.headers['content-type'] workflow.ImageBufferData = res.data After testing the flow, I got 404 error. Can anyone help?
o
What is the entire error? Can you send the message. It seemed to work in this thread: https://discord.com/channels/1108396290624213082/1361730853021155439
g
if you used the wizard set up, you wont have access to the correct meta token (as of the last time i tried this). if you want to be able to send and examine pictures in whatsapp, you must do the manual setup which takes longer.
s
I'm having the exact same problem, just with voice messages. I also get a 404 error. Since the code I used is exactly the same, maybe the error message I get will help: [7b4a75ab80] [bot-action] [flow:Main] [node:TranscribeTest] [card:"Fetch and Process Audio File from URL with Axios"]: Error executing action "inline-card:"Fetch and Process Audio File from URL with Axios".js" in flow:Main:node:TranscribeTest [Error, Request failed with status code 404 Transpiled Code: 003 async function __ROOT__() { 004 var __defProp = Object.defineProperty; 005 var __name = (target, value) => __defProp(target, "name", { 006 value, 007 configurable: true 008 }); 009 async function __ROOT__() { 010 const res = await axios.get(event.payload.audioUrl, { 011 headers: { 012 Authorization: "Bearer XXX" 013 } 014 }); 015 const rawFileContent = res.data; 016 const mimeType = res.headers["content-type"]; 017 } 018 __name(__ROOT__, "__ROOT__"); 019 ; 020 return await __ROOT__(); 021 ; 022 }; return await __ROOT__(); ]
Since I hardcoded the access token, I replaced it with XXX
This is what I was wondering about. If I use the set up wizard, I don't even create a meta app, so where do I get the access token from?
g
yeahh man, this is the issue i faced for a while. the problem is that botpress internally manages the token for you, and last time i checked, didnt expose the token for use. so any meta token you generate wont have the correct permissions/scope. I recomemnd doing the manual setup, it is abit tedious and long, but you have your own token then and can make the get request inside the bot with that access token and it will work correctly
s
Ok, thank you so much, I've been struggeling with this for days now and no one seemed to have the answer 😄
g
no stress brother, yeah i had the same issue a while back, there were a few threads from @agreeable-accountant-7248 on this topic, he found a way to do it. try look through some of the past threads from him as i cant find the ones. ps i hope u dont mind the mention Inaki!
I never ended up doing it my self as i found a workaround that doesnt use whatsapp
a
No problem, thanks for the mention, didn’t knew people is still having trouble with this. I found a workaround using make as bypass to download the WhatsApp image, send it to an LLM and then return the result to botpress. If this approach it’s ok for you I can share some screenshots.
f
Hello, @agreeable-accountant-7248 . I am interested in the approach you use with make as a bypass. Could you share more information about it with me? I would really appreciate it! Thank you in advance!
a
Hi. DM me so we can talk more in deep about your needs. Thank!
6 Views