Zain-ul-din / whatsapp-ai-bot

This is a WhatsApp AI bot that uses various AI models, including Gemini, GPT, DALL-E, and StabilityAI, to generate responses to user input.
https://wa-ai-seven.vercel.app/
MIT License
158 stars 87 forks source link

Can't generate QR code on headless ubuntu server #30

Closed rockydares closed 3 months ago

rockydares commented 3 months ago

Github codespace limit exceeded so trying to set this up on ubuntu server but as it has no chromium installed giving this error,

🤖 starting client...
â ‹ Whats App Client | generating QR Code...
/home/WhatsApp-Ai-bot/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
            reject(new Error([
                   ^

Error: Failed to launch the browser process!

Can QR code be shared via any other way?

Zain-ul-din commented 3 months ago

@rockydares it seems like your Ubuntu server has not installed Chromium on it OR it's not preventing Chromium from being open

Try to run this command, if this work

sudo apt-get install chromium-browser
rockydares commented 3 months ago

installing chromium did not help. Here is the full error log from cmd,

🤖 starting client...
â ‹ Whats App Client | generating QR Code...
/home/WhatsApp-Ai-bot/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
            reject(new Error([
                   ^

Error: Failed to launch the browser process!
/home/WhatsApp-Ai-bot/node_modules/whatsapp-web.js/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/home/WhatsApp-Ai-bot/node_modules/whatsapp-web.js/node_modules/puppeteer/src/node/BrowserRunner.ts:268:9)
    at Interface.<anonymous> (/home/WhatsApp-Ai-bot/node_modules/whatsapp-web.js/node_modules/puppeteer/src/node/BrowserRunner.ts:254:50)
    at Interface.emit (node:events:530:35)
    at Interface.close (node:internal/readline/interface:527:10)
    at Socket.onend (node:internal/readline/interface:253:10)
    at Socket.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Node.js v20.11.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
rockydares commented 3 months ago

Ok, this problem solved by installing these packages

sudo apt install libcups2 libnss3-dev librust-atk-sys-dev libatk-bridge2.0-dev librust-gtk-sys-dev

But now a new problem persists. After QR code login and authenticating nothing happens, !gemini !chatgpt nothing response. I have set my env values. Was working fine in workspace.

Zain-ul-din commented 3 months ago

@rockydares ensure the QR code is generating correctly and check this similar issue. If the problem continues, please let me know.

rockydares commented 3 months ago

Well, it was not working for my main account. My other account is working. I also face the QR code problem. On main cmd window it was showing QR code, but on screen or tmux session it was just question marks in square boxes, installed utf8 but it did not help. For running this script always on background I needed to run this on screen or tmux session. So I did this, ./setup.sh > qr_code.txt and this solved the problem.

One question, can this script take image as an input? Currently it does not. It would be awesome if it could. Thank You

Zain-ul-din commented 3 months ago

@rockydares yes, on some terminals QRCode not shows. to fix this you could also use the web version of this bot.

One question, can this script take image as an input? Currently it does not. It would be awesome if it could.

if you are referring this script to a bot then yes this bot takes images as input check this video.