Giter Club home page Giter Club logo

whatsapp-contact-sync's Introduction

WhatsApp Contact Sync

logo

Buy Me A Coffee

A simple web app for syncing the profile pictures from WhatsApp to Google Contacts.
The app matches contacts based on their phone numbers, and utilizes whatsapp-web.js and Google People API to update the profile picture in Google Contacts.

Demo

Why Was This Developed?

Whenever someone used to call me or I looked them up in my contacts, they all apear as colorful circles with a single letter in it.
The annoying part is that every single person I know has a WhatsApp account which has a profile picture. They are both based on the same phone number but the picture is only available in one of them.
In order to fix this grievence I developed this app which allows anyone to sync their contacts photos from WhatsApp to Google Contacts.

How To Use

The app is extremley easy to use (and self explantory):

  1. Go to whasync.com
  2. Press "Get Started"
  3. Scan the QR code with WhatsApp to authorize it
  4. Connect you Google account
  5. Choose you sync options
  6. That's it :)

The whole process is very simple and automated, so you don't need to worry about anything else.
Setting up should take less then a minute, and syncing should take about 1 second per photo (due to Google's API rate limitiations of 60 requests per user per minute)

How to Run Locally

In order for the backend to function, it requires an OAuth client id and secret + an API key.
Since (for obvious reasons) this is a private app, you will need to create one for your own.
You can see instructions on how to do that here.
Once you do that, create the file server/.env, and set the following environment variables:

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET

You also need to update the CLIENT_ID and API_KEY variables in web/src/pages/GoogleAuth.vue.

Once that's done, you can go ahead and run the app:

# Run backend
cd server
npm install
npm run dev

# Run web app
cd web
npm install
npm run dev

Build Docker Images

There are 3 different Dockerfiles for this app:

  • Dockerfile - This is an image containing both the backend and the web app
  • Dockerfile - An image containing only the web app
  • Dockerfile - An image containing only the backend

In order to build and run the complete app, you need to run the following commands:

docker build -t whasync .
docker run --rm -it -p 80:80 whasync

In order to build the seperate images for the backend and frontend, execute the following commands from the projects main directory:

docker build -t whasync-backend -f server/Dockerfile .
docker build -t whasync-web -f web/Dockerfile .

whatsapp-contact-sync's People

Contributors

dependabot[bot] avatar guyzyl avatar joaopna avatar repsay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

whatsapp-contact-sync's Issues

Help users to easily revoke access to the service

In terms of rights given, at the end of the process I had to go on my whatsapp parameters and google account parameters to revoke access to the app. I think that it would be nice that, at the end of the process, the webpage propose a couple of buttons to revoke the access (should be optional in case people want to regularly update their pictures)(I have no idea if this is technically possible).

Since this surely requires some decent amount of work, a temporary fix could be to provide instructions in a few lines, or a link redirecting to some tutorial

Add Dependabot for whatsapp-web.js

WhatsApp constantly update their web API which causes previous whatsapp-web.js to break.
Add Dependabot to the project so the whatsapp-web.js package is updated automatically.

ProtocolError: Protocol error (Network.getResponseBody): Target closed

Bug appears when performing these actions:

  1. Open WhaSync
  2. Link WhatsApp to WhaSync
  3. Go to WhaSync home screen
  4. Remove the new linked device on WhatsApp
  5. Press Continue / Get Started on WhaSync

This error causes the backend to crash.

Full error:

ProtocolError: Protocol error (Network.getResponseBody): Target closed.
    at whatsapp-contact-sync/server/node_modules/puppeteer/src/common/Connection.ts:304:16
    at new Promise (<anonymous>)
    at CDPSession.send (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/Connection.ts:300:12)
    at whatsapp-contact-sync/server/node_modules/puppeteer/src/common/HTTPResponse.ts:192:47
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HTTPResponse.text (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/HTTPResponse.ts:220:21)
    at async whatsapp-contact-sync/server/node_modules/whatsapp-web.js/src/Client.js:733:44 {
  originalMessage: ''

This error also sometimes appear:

Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
    at CDPSession.send (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/Connection.ts:286:9)
    at ExecutionContext._evaluateInternal (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/ExecutionContext.ts:254:44)
    at ExecutionContext.evaluate (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/ExecutionContext.ts:140:23)
    at DOMWorld.evaluate (whatsapp-contact-sync/server/node_modules/puppeteer/src/common/DOMWorld.ts:174:20)

Add screenshot / gif to READE.md

Currently the README.md file doesn't have a screenshot for gif of the service.
I think adding one will make the project more appealing and cause more people to use it, and therefore should be added.

Nothing happens after scanning QR code

Hello,

I wanted to let you know that nothing happens for me after scanning the QR code from the "Linked devices" screen. I am using the latest Whatsapp version on Android and tried whasync.com on both Firefox and Chrome. The console and network tab don't show any error or relevant information of what is going wrong.

Thank you!

QR doesn't appear on first load if container was just launched

The website is currently hosted on GCP Run. That means that when no one is accessing the website the Docker container is taken down, and a new one is created when someone accesses the website.
In addition to that, the app is based whatsapp-api.js which uses a headless Chrome browser to function.

The combination of these two facts causes some sort of bug where after the container is launched, the QR isn't loaded and a reload to the page is required.

Get rid of web sockets

The project currently uses web sockets (WS) in order to update the frontend from the backend. This is necessary for things such as updating the WhatsApp QR code, and updating the sync progress.
Although it works, it causes issues when put together with the Express session management (for example #22, #23).

Removing the WS logic from the backend+frontend should make the code simpler, and less prone to errors.

Replace whatsapp-web.js with Baileys

Currently, the projects is fully based on whatsapp-web.js.
It's a very good open source project, but the problem is that in order to interact with the WhatsApp web API, it opens a headless Chrome browser which is very inefficient.

That's where Baileys comes in.
It's a library which provides a full WhatsApp web API, but does so without requiring a headless Chrome browser.
This should make the code both faster and more efficient.

Just a comment

First of all thanks for your work, it works very well!

Just a few comments maybe :

  • in terms of safety maybe you could add a paragraph in your README explaining how giving your app the required access does not mean you are going to steal some data. I am saying this thinking about "my parents" or anybody wanting to use this without any prior knowledge of what's going on
  • still in terms of rights given, at the end of the process I had to go on my whatsapp parameters and google account parameters to revoke access to the app. I think that it would be nice that, at the end of the process, the webpage propose a couple of buttons to revoke the access (should be optional in case people want to regularly update their pictures)(I have no idea if this is technically possible).
  • A last comment : Before the sync there is an option to overwrite existing pictures. I think that I would have liked to decide this picture by picture!

Fail to start docker container

After I have built the image (the one that contains both the backend and web), when I try starting it by doing this:

docker run --rm --name whasync -it -p:8081:80 whasync

I see this error:

standard_init_linux.go:230: exec user process caused: no such file or directory

If it helps, I am building my container on a Synology NAS with Intel Celeron J4025.

I have no clue if the server/.env content has anything to do with the problem I am facing. I do the image building after creating the server/.env file and modifying the web/src/pages/GoogleAuth.vue files. And I am wondering if the .env file should have the following content, with no quotes, and nothing else...

GOOGLE_CLIENT_ID=<masked>.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<masked>-<masked>

[Bug] TimeoutError: Timed out after 30000 ms while trying to connect to the browser!

TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r982053 is guaranteed to work.
    at Timeout.onTimeout (/app/server/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:252:20)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Calling of `client.getProfilePicUrl` slows down sync

When syncing, for every match between a Google and a WhatsApp contact the whatsapp.downloadFile function is called.
Within it, the function getProfilePicUrl is called to get the URL of the profile picture of the user.

The problem is that not all contacts have a profile pic, so calling getProfilePicUrl (takes ~1 second) is a waste of time and slows down the whole sync process.
Need to find a way to improve this step of the sync process.

[Bug] Error: Evaluation failed: Error: Comms::sendIq called before startComms

Error: Evaluation failed: Error: Comms::sendIq called before startComms
    at t.default (https://web.whatsapp.com/:2:398)
    at O (https://web.whatsapp.com/app.4bd18721b02591a90502.js:219:127040)
    at https://web.whatsapp.com/app.4bd18721b02591a90502.js:219:126033
    at new Promise (<anonymous>)
    at P (https://web.whatsapp.com/app.4bd18721b02591a90502.js:219:126008)
    at t.sendSmaxStanza (https://web.whatsapp.com/app.4bd18721b02591a90502.js:219:116470)
    at https://web.whatsapp.com/app.4bd18721b02591a90502.js:219:636846
    at Generator.next (<anonymous>)
    at t (https://web.whatsapp.com/vendor1~app.6bd0798bf8d46303b447.js:2:32250)
    at s (https://web.whatsapp.com/vendor1~app.6bd0798bf8d46303b447.js:2:32461)
    at ExecutionContext._evaluateInternal (/app/server/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 

Incomplete loading of photos (blurry photos) in WhatsApp contacts sync with Google Contacts

Issue: Incomplete loading of photos in WhatsApp contacts sync with Google Contacts

Description: Occasionally, the photos of contacts in WhatsApp do not fully load, even though they are successfully synced to Google Contacts. These partially loaded photos appear blurry.

Steps to reproduce:

  1. Open the WhatsApp Contact Sync website.
  2. Initiate a sync process between WhatsApp and Google Contacts.
  3. Observe the synced contacts in Google Contacts.
  4. Note that some photos may not be completely loaded and appear blurry.

Expected behavior: All photos should be fully loaded and displayed clearly in Google Contacts after the sync process.

Additional information:

  • This issue occurs intermittently and does not affect all contacts.

Please find attached any relevant error logs or screenshots for further analysis.

Please let me know if you need any further information or clarification regarding this issue.

Thank you for your attention to this matter.

[Bug] GaxiosError: Requested entity was not found.

GaxiosError: Internal error encountered.
    at Gaxios._request (/app/server/node_modules/gaxios/build/src/gaxios.js:130:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async OAuth2Client.requestAsync (/app/server/node_modules/google-auth-library/build/src/auth/oauth2client.js:368:18)

Limited number of contacts?

I can only sync ~52 of my contacts pictures, even though I have hundreds. Is this an app ou Google API limitation? Any way to overcome?

Add/improve explanations relative to data safety

In terms of safety maybe you could add a paragraph in your README explaining how giving your app the required access does not mean you are going to steal some data. I am saying this thinking about "my parents" or anybody wanting to use this without any prior knowledge of what's going on

It doesn't seem to work anymore

I downloaded the code, ran the docker commands, loaded the page, scanned the QR Code and WhatsApp recognized and connected to another session successfully. However, the page keeps showing the QR Code, as if I had not connected yet, for over 5 minutes.

Am I supposed to wait longer? I don't see any error on the console log that might indicate any problem. Not sure if the .env credentials are correct, but there was no warning pointing to this problem.

The whasync.com demo website also seems to be hanging on the QR code

Docker Build Fails due to TypeScript Error in web/src/main.ts

Hello,

I encountered an issue while trying to build the Docker image for the whatsapp-contact-sync project. The build process fails during the npm run build step for the web-build with a TypeScript error.

The error message is as follows:

src/main.ts(68,41): error TS2345: Argument of type '{ pageTrackerTemplate(to: RouteLocationNormalized): { page_title: string; page_path: string; }; config: { id: string; }; }' is not assignable to parameter of type 'PluginOptions'.
Types of property 'pageTrackerTemplate' are incompatible.
Type '(to: RouteLocationNormalized) => { page_title: string; page_path: string; }' is not assignable to type '() => PageView'. 

It appears there's a type mismatch between the pageTrackerTemplate function and the PluginOptions type. The pageTrackerTemplate function seems to be expecting no arguments and a return type of PageView, but the provided function takes a RouteLocationNormalized argument and returns an object with page_title and page_path.

Cannot build image from dockerfile

I see this when I try to build docker image and container:

root@machine # docker build -t whasync .
Sending build context to Docker daemon  3.072kB
Step 1/31 : FROM node:20-alpine AS web-build
20-alpine: Pulling from library/node
96526aa774ef: Pull complete
a78c46279494: Pull complete
b0147fefb4fa: Pull complete
e6b541644ba7: Pull complete
Digest: sha256:2a3288a397c721c12f0743b197b9a040e278c10d38f806b3c0023d9e2e06e111
Status: Downloaded newer image for node:20-alpine
 ---> 44fa888c2209
Step 2/31 : WORKDIR /app/web
 ---> Running in 71f84e7b407a
Removing intermediate container 71f84e7b407a
 ---> e29171dfd094
Step 3/31 : COPY ["web/package.json", "web/package-lock.json*", "./"]
COPY failed: file not found in build context or excluded by .dockerignore: stat web/package.json: file does not exist

Syncing Contacts Not Working on Docker, Locally, or via Website

Hello,

I'm having an issue with the contact syncing feature of the whatsapp-contact-sync tool. When I try to sync my contacts, whether it's on Docker, locally, or through the whasync.com website, it doesn't seem to perform any actions and immediately reports that it's done.

Here are the steps I've taken:

  1. I log into the tool successfully.
  2. I attempt to sync my contacts.
  3. The tool does nothing noticeable and immediately reports that the syncing process is done.

There are no error messages or any indications of what could be wrong. The login process works fine, so it seems to be specifically an issue with the syncing feature.

Could you please look into this? I'd appreciate any help or guidance.

Thank you.

Error when starting sync

I installed the app locally and tried to run it. When starting sync, got this error on server and it didn't move any further:

TypeError: Cannot read properties of undefined (reading '0')
    at /Users/meneses/git/whatsapp-contact-sync/server/src/gapi.ts:48:36
    at Array.map (<anonymous>)
    at /Users/meneses/git/whatsapp-contact-sync/server/src/gapi.ts:44:8
    at Generator.next (<anonymous>)
    at fulfilled (/Users/meneses/git/whatsapp-contact-sync/server/src/gapi.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[nodemon] app crashed - waiting for file changes before starting...

Can you please help?
(Will buy you a coffee if this works)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.