open-wa / wa-automate-nodejs

πŸ’¬ πŸ€– The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.15k stars 600 forks source link

Error when starting a conversation #2852

Closed fejorca closed 2 years ago

fejorca commented 2 years ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Tested and experienced on both

What type of host account are you experiencing this issue on?

Business account

Mode

EASY API/CLI

Current Behavior

I'm trying to connect it to chatwoot using the tutorial here on github but after testing either easy api or docker the error is the same, I've deleted everything related to chatwoot but even so wa-automate crashes everytime I send a message

Expected Behavior

WA-Automate should connect to chatwoot OR at least doesn't crash when using without connecting to chatwoot

Steps To Reproduce

Using terminal type:

docker run -d -p 3256:8080 --init openwa/wa-automate -w https://waautomate.site --chatwoot-url "https://chatwoot.site/api/v1/accounts/1/inbox/1" --chatwoot-api-access-token CHATWOOTAPIACCESSTOKEN --socket

create() code OR full CLI command + CONFIG

- Patches Installed: 04a98
- Client loaded for business account [MD] with 769 contacts, 3 chats & 26 messages in 14.518s
- Finalizing web session...
- Finalizing client...
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                       β”‚
β”‚   Use the link below to easily report issues:πŸ‘‡πŸ‘‡πŸ‘‡   β”‚
β”‚                                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
- https://github.com/open-wa/wa-automate-nodejs/issues/new?template=bug_report.yaml&d_info=%7B%0A%20%20%22WA_VERSION%22:%20%222.2232.7%22,%0A%20%20%22WA_AUTOMATE_VERSION%22:%20%224.44.5%22,%0A%20%20%22BROWSER_VERSION%22:%20%22HeadlessChrome/105.0.5195.19%22,%0A%20%20%22START_TS%22:%201661533060596,%0A%20%20%22RAM_INFO%22:%20%22Total:%2025.15%20GB%20%7C%20Free:%2023.98%20GB%22,%0A%20%20%22PPTR_VERSION%22:%20%2215.0.0%22,%0A%20%20%22LATEST_VERSION%22:%20true,%0A%20%20%22CLI%22:%20true,%0A%20%20%22PATCH_HASH%22:%20%2204a98%22,%0A%20%20%22LAUNCH_TIME_MS%22:%2014518,%0A%20%20%22ACC_TYPE%22:%20%22BUSINESS%22,%0A%20%20%22chats%22:%203,%0A%20%20%22messages%22:%2026,%0A%20%20%22contacts%22:%20769,%0A%20%20%22isBiz%22:%20true,%0A%20%20%22isMd%22:%20true,%0A%20%20%22INSTANCE_ID%22:%20%226ff8097c-53e3-472b-b8d0-c3230444fd8b%22%0A%7D&enviro=-%20OS:%20Linux%205.15%0A-%20Node:%2018.7.0%0A-%20npm:%208.15.0&labels=CLI,MD,BHA
- πŸš€ @OPEN-WA ready for account: 4934
- session_STARTUP
- Setting Up Chatwoot handler
- Make sure to set up the Chatwoot inbox webhook to the following path on this process: /chatwoot
Please set the chatwoot inbox webhook to this sessions URL with path /chatwoot
- Chatwoot handler set up successfully
- Setting Up API Explorer
- API Explorer set up successfully
- Setting up socket
- Socket ready for connection
- ...waiting for port 8080 to be free
- Port 8080 is now free.
- 
    API Explorer (​http://localhost:8080/api-docs/ ​)
- 
β€’ Listening on port 8080!
TypeError: Cannot read properties of undefined (reading 'id')
    at /usr/src/app/node_modules/@open-wa/wa-automate/dist/cli/integrations/chatwoot.js:232:95
    at Generator.next (<anonymous>)
    at fulfilled (/usr/src/app/node_modules/@open-wa/wa-automate/dist/cli/integrations/chatwoot.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Starting the application
Using version: latest
./node_modules/@open-wa/wa-automate/bin/server.js --in-docker --qr-timeout 0 --popup --debug --force-port https://waautomate.site --chatwoot-url "https://chatwoot.site/api/v1/accounts/1/inbox/1" --chatwoot-api-access-token CHATWOOTAPIACCESSTOKEN --socket

up to date, audited 1038 packages in 2s

83 packages are looking for funding
  run `npm fund` for details

16 vulnerabilities (6 moderate, 7 high, 3 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Unable to read config file json: /config
- session_STARTUP
- webhooks set already
- DEBUG - PORT: 8080
- DEBUG - flags: {"sessionId":"session","executablePath":"/usr/bin/google-chrome","popup":true,"disableSpins":true,"cliConfig":"/config","useChrome":true,"port":8080,"inDocker":true,"qrTimeout":0,"debug":true,"forcePort":true,"webhook":"https://waautomate.site","chatwootUrl":"https://chatwoot.site/api/v1/accounts/2/inbox/17","chatwootApiAccessToken":"CHATWOOTAPIACCESSTOKEN","socket":true,"noApi":false,"host":"localhost","verbose":false,"ef":["qr","STARTUP","MD_DETECT"],"allowSessionDataWh":false,"generateApiDocs":true,"sessionDataOnly":false,"skipSavePostmanCollection":false,"headful":false,"preAuthDocs":false,"stats":false,"noKillOnLogout":false,"cors":false,"emitUnread":false,"allowIps":[]}
- DEBUG - env vars: {"WA_EXECUTABLE_PATH":"/usr/bin/google-chrome","WA_POPUP":"true","WA_DISABLE_SPINS":"true","WA_CLI_CONFIG":"/config","WA_USE_CHROME":"true","WA_PORT":"8080"}
- Launching EASY API
- Selected port is free
- Generating Swagger Spec
- Postman collection generated: open-wa-session.postman_collection.json
- API collections (swagger + postman) generated successfully
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃                                                                              ┃┃   @open-wa/wa-automate                                                       ┃┃   πŸ’¬ πŸ€– The most reliable NodeJS whatsapp library for chatbots with          ┃┃   advanced features.                                                         ┃┃   Version: 4.44.5                                                            ┃┃   Check out the latest changes:                                              ┃┃   https://github.com/open-wa/wa-automate-nodejs#latest-changes               ┃┃                                                                              ┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
You can also authenticate the session at: http://localhost:8080
- Starting
- Version: 4.44.5
- Initializing WA
- Using custom chromium args with multi device will cause issues! Please remove them: 
- Launching Browser
- MD Enabled, turning off incognito mode.
- Data dir: /sessions/_IGNORE_session
- Browser launched: 93ms
- Setting Up Page
- Loading session data
- Found session data file: /usr/src/app/session.data.json
- No session data detected. Opting in for MD.
- Make sure to keep the session alive for at least 5 minutes after scanning the QR code before trying to restart a session!!
- Pre page launch setup complete: 5ms
- Navigating to WA
- Page loaded in 334ms: 200
- Page loaded
- Debug info: {
  "WA_VERSION": "2.2232.7",
  "PAGE_UA": "WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
  "WA_AUTOMATE_VERSION": "4.44.5",
  "BROWSER_VERSION": "HeadlessChrome/105.0.5195.19",
  "OS": "Linux 5.15",
  "START_TS": 1661533101549,
  "RAM_INFO": "Total: 25.15 GB | Free: 23.98 GB",
  "PPTR_VERSION": "15.0.0"
}
- Use this easy pre-filled link to report an issue: https://github.com/open-wa/wa-automate-nodejs/issues/new?template=bug_report.yaml&d_info=%7B%0A%20%20%22WA_VERSION%22:%20%222.2232.7%22,%0A%20%20%22WA_AUTOMATE_VERSION%22:%20%224.44.5%22,%0A%20%20%22BROWSER_VERSION%22:%20%22HeadlessChrome/105.0.5195.19%22,%0A%20%20%22START_TS%22:%201661533101549,%0A%20%20%22RAM_INFO%22:%20%22Total:%2025.15%20GB%20%7C%20Free:%2023.98%20GB%22,%0A%20%20%22PPTR_VERSION%22:%20%2215.0.0%22,%0A%20%20%22LATEST_VERSION%22:%20true,%0A%20%20%22CLI%22:%20true%0A%7D&enviro=-%20OS:%20Linux%205.15%0A-%20Node:%2018.7.0%0A-%20npm:%208.15.0&labels=CLI,MD
- Time to injection: 797ms
- Injecting api
- Injecting scripts
- Base inject: 15ms
- WAPI inject: 10ms
- Checking session integrity
- Session integrity check passed
- Launch inject: 503ms
- WAPI injected
- Authenticating

DEBUG INFO

{
  "WA_VERSION": "2.2232.7",
  "WA_AUTOMATE_VERSION": "4.44.5",
  "BROWSER_VERSION": "HeadlessChrome/105.0.5195.19",
  "START_TS": 1661532532329,
  "RAM_INFO": "Total: 25.15 GB | Free: 23.97 GB",
  "PPTR_VERSION": "15.0.0",
  "LATEST_VERSION": true,
  "CLI": true,
  "PATCH_HASH": "04a98",
  "LAUNCH_TIME_MS": 14575,
  "ACC_TYPE": "BUSINESS",
  "chats": 3,
  "messages": 25,
  "contacts": 769,
  "isBiz": true,
  "isMd": true,
  "INSTANCE_ID": "990a1cc3-419a-4cd7-b270-3f0d6cad8f6f"
}

Environment

- OS: Linux 5.15
- Node: 18.7.0
- npm: 8.15.0

Screenshots/Logs

No response

Anything else?

No response

smashah commented 2 years ago

You say it's crashing when starting a conversation but only included the logs up to "authenticating". please include all of the logs up to the crash and use --verbose

smashah commented 2 years ago

Which version of chatwoot are you using?

fejorca commented 2 years ago

You say it's crashing when starting a conversation but only included the logs up to "authenticating". please include all of the logs up to the crash and use --verbose

EDIT: was not complete EDIT 2: pastebin link

Here's the log

https://pastebin.com/dQmy60SD

fejorca commented 2 years ago

Which version of chatwoot are you using?

v2.8.1

fejorca commented 2 years ago

By some sort of wizardry now is working but I'm having another issue, the docker command works as expected