GithubHelp home page GithubHelp logo

open-wa / wa-automate-nodejs Goto Github PK

View Code? Open in Web Editor NEW
3.1K 106.0 592.0 168 MB

๐Ÿ’ฌ ๐Ÿค– The most reliable tool for chatbots with advanced features. Be sure to ๐ŸŒŸ this repository for updates!

Home Page: https://docs.openwa.dev/

License: Other

TypeScript 83.93% JavaScript 13.62% HTML 0.64% Handlebars 0.08% CSS 0.66% SCSS 0.16% MDX 0.90%
typescript chatbots nodejs framework api

wa-automate-nodejs's People

Contributors

13banda avatar andersondeoliveiramachado avatar apnerve avatar basboot avatar bbayugt avatar christianfds avatar danielcardeenas avatar deepsourcebot avatar dependabot-preview[bot] avatar dependabot[bot] avatar feliperaul avatar github-actions[bot] avatar greenkeeper[bot] avatar jersonjunior avatar jesusvalverde avatar lxndr-rl avatar m7mdcc avatar marcelocecin avatar marcosjohnny avatar moonlgh avatar mrodal avatar nanaksr avatar phantom-limb avatar rzlnhd avatar sandro-salles avatar scropion86 avatar smashah avatar theonlyjohnny avatar unknown-consortium avatar zagbutnozig 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  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

wa-automate-nodejs's Issues

Problem to read qrcode capured

I cannot read the qrcode captured with method bellow:

sulla.ev.on('qr', async qrcode => {
//qrcode is base64 encoded qr code image
//now you can do whatever you want with it
const imageBuffer = Buffer.from(
qrcode.replace('data:image/png;base64,', ''),
'base64'
);
fs.writeFileSync('qr_code.png', imageBuffer);
});

The quality of image is very bad.

Bug Ubuntu Linux 'eventEmitter2 loader.js error'

Development worked perfectly on OSX, when the production byproduct to run a final test presented a problem 'eventEmitter2 loader.js error'.

I am still exploring what it can be. If anyone has any information as to what this error is occurring. Appreciate!

Congratulations on the project =)

authenticate

the qrcode loader is undefined when the session was previously created

Managing multiple sessions

how can manage two or more phone number sessions. and how can identify which session related with which phone number.

Send images

Hi, can you comment on an implementation of sending images?

Detect if the main device is online

I have a use case where I need some alert when the main device is offline.

The method I found is WAPI.isConnected, essentially detecting the 'Phone not connected' banner in the UI.

However it doesn't work as in the method doesn't return false when the main device is offline.

The command document.querySelector('*[data-icon="alert-phone"]') is working in web.whatsapp browser.

Anyone have ideas?

installation error

help me with the installation commands.

without using this command npm i --save sulla-hotfix
Only with the cloning of your project.

DEADLINE_EXCEEDED: Deadline exceeded

I'm trying to import 50,000 contacts and get this error:

(node:36093) UnhandledPromiseRejectionWarning: Error: 4 DEADLINE_EXCEEDED: Deadline exceeded
at Object.callErrorFromStatus (/project/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
at Http2CallStream.call.on (/project/node_modules/@grpc/grpc-js/build/src/client.js:96:33)
at Http2CallStream.emit (events.js:203:15)
at process.nextTick (/project/node_modules/@grpc/grpc-js/build/src/call-stream.js:75:22)
at process._tickCallback (internal/process/next_tick.js:61:11)

Error "sulla-hotfix": "^1.2.11" version after getAllMessagesInChat method

Hello,

I'm trying to use the 1.2.11 version and the method bellow are getting error:

  • getAllMessagesInChat
  • getGroupMembersId

Message error:

(node:49060) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'participants' of undefined
at Object.window.WAPI._getGroupParticipants (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/lib/wapi.js:548:21)
at async Object.window.WAPI.getGroupParticipantIDs (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/lib/wapi.js:559:21)
at ExecutionContext._evaluateInternal (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at ExecutionContext. (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/helper.js:111:15)
at DOMWorld.evaluate (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/DOMWorld.js:112:20)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at Frame. (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/helper.js:111:15)
at Page.evaluate (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/Page.js:863:43)
at Page. (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/puppeteer/lib/helper.js:112:23)
at Whatsapp. (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:164:50)
at step (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:33:23)
at Object.next (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:14:53)
at /Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:8:71
at new Promise ()
at __awaiter (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:4:12)
at Whatsapp.getGroupMembersId (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/sulla-hotfix/dist/api/whatsapp.js:161:16)
at /Users/foka/dev/workspace-estudos/whatsapp/src/router/whatsrouter.js:53:16
at Layer.handle [as handle_request] (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/foka/dev/workspace-estudos/whatsapp/node_modules/express/lib/router/route.js:137:13)

Decrypting Media

Describe the bug
decryptMedia() function is not working.

sulla-hotfix version
1.5.7

Whatsapp version
0.4.315

Error: Evaluation failed: TypeError: Cannot read property 'sendMessage' of undefined

Hey I am getting the following error while getting messages using chat id

const chatMessages = await client.getAllMessagesInChat( {chatId: chat.id, includeMe: true, includeNotifications: true} ).then(message => { console.log(message); }).catch((error) => { console.error(error); });
can you please help / guide; what am I doing wrong?

Error: Evaluation failed: TypeError: Cannot read property 'sendMessage' of undefined at Object.window.WAPI.getChat (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\lib\wapi.js:289:32) at Object.window.WAPI.getAllMessagesInChat (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\lib\wapi.js:618:23) at __puppeteer_evaluation_script__:3:41 at ExecutionContext._evaluateInternal (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\ExecutionContext.js:122:13) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7) -- ASYNC -- at ExecutionContext.<anonymous> (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\helper.js:111:15) at DOMWorld.evaluate (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\DOMWorld.js:112:20) at <anonymous> -- ASYNC -- at Frame.<anonymous> (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\helper.js:111:15) at Page.evaluate (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\Page.js:863:43) at Page.<anonymous> (C:\wamp64\www\sulla-hotfix\node_modules\puppeteer\lib\helper.js:112:23) at Whatsapp.<anonymous> (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:245:50) at step (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:33:23) at Object.next (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:14:53) at C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:8:71 at new Promise (<anonymous>) at __awaiter (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:4:12) at Whatsapp.getAllMessagesInChat (C:\wamp64\www\sulla-hotfix\node_modules\sulla-hotfix\dist\api\whatsapp.js:242:16) at allChats.forEach (C:\wamp64\www\sulla-hotfix\index.js:16:37) at Array.forEach (<anonymous>) at start (C:\wamp64\www\sulla-hotfix\index.js:15:11) at <anonymous>

How could you send a contact?

How could you send a contact? I have tried in many ways without success

// import { create, Whatsapp } from 'sulla-hotfix';
const sulla = require('sulla');

sulla.create().then(client => start(client));

function start(client) {
  client.onMessage(message => {
    if (message.body === 'Hi') {
      client.sendText(message.from, '๐Ÿ‘‹ Hello from sulla!');
      //Sending a contact here
			try {
			  client.sendText(message.from, 'begin ---------');
			  client.sendContact(message.from,client.getContact(message.from));           
			  client.sendText(message.from, 'end -----------');

		  } catch (err) {
			console.log(err.message);
		}             
    }
  });
}

Get all live locations being shared with client

It would be cool if I can have something like:

client.getLiveLocations()

to see who is sharing their live locations with me and then subsequently I would be able to provide them with some geographically contextual response.

Notes:
In order to grab live locations from whatsapp web right now you can enter this into the console:

window.Store.LiveLocation.toJSON().forEach(l=>{console.log(l.participants[0].id._serialized,l.participants[0].lat, l.participants[0].lng,new Date(l.participants[0].expiration*1000))})

Automatically click use here when switching systems

Scenario:
Develop on macbook => scan qr code
Deploy on server => scan qr code
Develop on macbook => Gets stuck on qr code, need to delete sessions, scan qr code
Deploy on server => Gets stuck on qr code, need to delete sessions, scan qr code

Example

Send Location - Help

I can't make sendLocation work.

My code

const sulla = require('sulla-hotfix');

sulla.create().then(client => start(client));

function start(client) {
	client.onMessage(async message => {
		if (message.body === 'Hi') {
			await client.sendText(message.from, '๐Ÿ‘‹ Hello from sulla!'); //It's working
		}    
		if (message.body === 'Local') {
			console.log("Local"); //It's working
			await client.sendLocation(message.from, '-19.922783', '-43.945161',  'My Local'); //This is not working
		}
		await client.simulateTyping(message.from,true);//It's working
	});
}

Send video

sendImage and sendFile do not handle video messaging(. I have a base64 like
let mediaData = 'data:{mime};base64,{base64}' where mime is geeting with npm: mime-types. I have no message delivered with this piece(

Problem with qr code.

I have problem, the qr code is loading forever, the phone can not read the console version, but the browser yes!


TypeError: Cannot read property 'sendMessage' of undefined

Tried sending an text today, error thrown was
`(node:6383) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'sendMessage' of undefined

at Object.window.WAPI.getChat (/home/menudib/Desktop/Chatbot/node_modules/sulla-hotfix/dist/lib/wapi.js:289:32)

at Object.window.WAPI.sendSeen (/home/menudib/Desktop/Chatbot/node_modules/sulla-hotfix/dist/lib/wapi.js:828:28)

at puppeteer_evaluation_script:3:34`

Send message to a new number?

Currently, I can only send a message to contacts who already have a conversation started. When I try to send to a new error contact.

UnhandledPromiseRejectionWarning: Error: Page crashed!

The following error occurs randomly without any apparent reason.

whatsapp_1  | (node:1) UnhandledPromiseRejectionWarning: Error: Page crashed!
whatsapp_1  |     at Page._onTargetCrashed (/app/node_modules/puppeteer/lib/Page.js:216:24)
whatsapp_1  |     at CDPSession.Page.client.on.event (/app/node_modules/puppeteer/lib/Page.js:124:56)
whatsapp_1  |     at CDPSession.emit (events.js:198:13)
whatsapp_1  |     at CDPSession._onMessage (/app/node_modules/puppeteer/lib/Connection.js:200:12)
whatsapp_1  |     at Connection._onMessage (/app/node_modules/puppeteer/lib/Connection.js:112:17)
whatsapp_1  |     at WebSocketTransport._ws.addEventListener.event (/app/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
whatsapp_1  |     at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:120:16)
whatsapp_1  |     at WebSocket.emit (events.js:198:13)
whatsapp_1  |     at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:789:20)
whatsapp_1  |     at Receiver.emit (events.js:198:13)
whatsapp_1  |     at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:422:14)
whatsapp_1  |     at Receiver.getData (/app/node_modules/ws/lib/receiver.js:352:17)
whatsapp_1  |     at Receiver.startLoop (/app/node_modules/ws/lib/receiver.js:138:22)
whatsapp_1  |     at Receiver._write (/app/node_modules/ws/lib/receiver.js:74:10)
whatsapp_1  |     at doWrite (_stream_writable.js:415:12)
whatsapp_1  |     at writeOrBuffer (_stream_writable.js:399:5)
whatsapp_1  |     at Receiver.Writable.write (_stream_writable.js:299:11)
whatsapp_1  |     at Socket.socketOnData (/app/node_modules/ws/lib/websocket.js:864:35)
whatsapp_1  |     at Socket.emit (events.js:198:13)
whatsapp_1  |     at addChunk (_stream_readable.js:287:12)
whatsapp_1  |     at readableAddChunk (_stream_readable.js:268:11)
whatsapp_1  |     at Socket.Readable.push (_stream_readable.js:223:10)
whatsapp_1  | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)
whatsapp_1  | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This error doesn't kill the node process, so the container never restart and, therefore, the bot stop working.
Can you help me find why this error occurs?

check if session is still valid from outside?

Hi,

Is there any simple way to check if it's connected and still working after sulla create?
sulla.create().then(client => start(client));

I wanted to check if it's connected but the code is running so how can I check from outside? Can I check in the session folder for something?

Can't send large images

I can send media without problems but when it comes to an image > 200k it fails not errors caught nothing

Multiple authentication Qr

Hi! I want to listen on "qr" event only for specific whatsapp phone/account.
The problem is "qr" event is emitted each time a phone number wants to authenticate, so I can't no which phone exactly is about to scan the code.

I'm asking if you can implement dynamic events emitter for the qr code scanning.

I was thinking about something like:

    let dynamicEventId1: string = 'one_id'
    let dynamicEventId2: string = 'another_id'
    const qrcode1 = 'data:image/png;base64,...'
    const qrcode2 = 'data:image/png;base64,...'

    // Create the session instance with the specific event id.
    sullaHotfix.create('session1', puppeteerConfigOverride, customAgent, /*options*/{eventId = dynamicEventId1})
    sullaHotfix.create('session2', puppeteerConfigOverride, customAgent,  /*options*/{eventId = dynamicEventId2})

    // Listen All (look at the param "eventId")
    ev.on(`qr`, (qrcode, eventId) => {
      if (eventId === dynamicEventId1) {
        //
      } else if (eventId === dynamicEventId2) {
        // 
      }
    })

    // Emit all (look at the param "eventId")
    ev.emit(`qr`, qrcode, dynamicEventId1)
    ev.emit(`qr`, qrcode, dynamicEventId2)

or

    let dynamicEventId1: string = 'one_id'
    let dynamicEventId2: string = 'another_id'
    const qrcode1 = 'data:image/png;base64,...'
    const qrcode2 = 'data:image/png;base64,...'
    
    // Create the session instance with the specific event id.
    sullaHotfix.create('session1', puppeteerConfigOverride, customAgent, /*options*/{eventId = dynamicEventId1})
    sullaHotfix.create('session2', puppeteerConfigOverride, customAgent,  /*options*/{eventId = dynamicEventId2})
    
    // Listen on only one specific id
    ev.on(`qr/${dynamicEventId1}`, (qrcode, eventId) => {
      // 
    })
    
    // Listen All
    ev.on(`qr`, qrcode => {
      // 
    })
    
    // Emit for only one specific id.
    ev.emit(`qr/${dynamicEventId1}`, qrcode, dynamicEventId)
    
    // Emit all
    ev.emit(`qr`, qrcode)

Sending video

Hi guys, anyone of you tried sending a video?

This is my code:

const fileBase64 = "data:video/mp4;base64,....";
 
await client.sendFile(
    to,
    fileBase64,
    "Video.mp4",
    "Video"
);

The message can be sent, but the message rendered as 'file' type instead of a 'video' message.
Image of Yaktocat

It's possible to send a link with thumb?

I'am trying to send an link with thumbnail but i realize this functions does not exist yet in library, anyone already develop this function by ourselves? I've tried to send but don't know why not function properly, someone can help me?

i see function WAPI.sendMessageWithThumb already exist but i did not realize how to use that, look my attempt of develop:

Whatsapp.prototype.sendMessageWithThumb = function (to, thumb,url,title,description) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, this.page.evaluate(function (_a) { var to = _a.to, thumb = _a.thumb, url = _a.url, title = _a.title, description = _a.description; return WAPI.sendMessageWithThumb(thumb, url, title, description, to); },{ to: to, thumb: thumb, url: url, title: title, description: description })]; case 1: return [2, _a.sent()]; } }); }); };

Captura de Tela 2020-01-19 aฬ€s 18 20 55

#Edit
Making a screen capture from puppeteer and this is showed
Captura de Tela 2020-01-19 aฬ€s 18 23 23

in a file: whatsapp.js

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.