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

Detect incoming call #261

Closed itzharDev closed 3 years ago

itzharDev commented 4 years ago

Is there any event for incoming call?

For bots is good to auto reject for calls

marcelocecin commented 4 years ago

https://github.com/alfred82santa/whalesong/blob/6837ee3091e64f95166a4588a48395f262ba833e/whalesong/managers/message.py

jesusvalverde commented 4 years ago

not able to fin anything ...but sound a great idea

smashah commented 4 years ago

I've spent some time on it. It's simple enough to listen to a call event but because Whatsapp web doesn't actually deal with calls, I can't get it to reject the call even, yet.

itzharDev commented 4 years ago

I think reject is nice to have, but not mandatory

smashah commented 4 years ago

@github-actions run

⚡ Release! ⚡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i`); exec(`npm run release-ci`); var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); })(); ```
smashah commented 4 years ago

Changelog

🚀 Release 1.8.33 (2020-04-05)

smashah commented 4 years ago

@itzharDev you can now use client.onIncomingCall

https://smashah.github.io/sulla/classes/whatsapp.html#onincomingcall

Here's the call object interface: https://github.com/smashah/sulla/blob/master/src/api/model/call.ts peerJid is the number of the caller.

client.onIncomingCall(call=>console.log('newcall',call));

Let me know if this works for you. There may be a solution to rejecting the call but its a slim chance.

Thanks

tinyCoder32 commented 4 years ago

Thank you so much, Is there a way to reject or accept the incoming call please?

smashah commented 4 years ago

@tinyCoder32 not right yet maybe in the future.

smashah commented 4 years ago

This is tested so closing for now. Report back if there are further issues.

smashah commented 3 years ago

Apparently call rejection is possible now. Reopening to implement rejectCall

malakaisbest commented 3 years ago

I'm new to open-wa. is there any "Easy API" parameter to detect call and send a reply to the caller?

jesusvalverde commented 3 years ago

A reply as a text...yes

client.onIncomingCall(call => { client.sendText(call.peerJid, 'Lo sentimos, pero no podemos atender su llamada, por favor envienos un audio o un mensaje con su consulta');
; });

malakaisbest commented 3 years ago

A reply as a text...yes

client.onIncomingCall(call => { client.sendText(call.peerJid, 'Lo sentimos, pero no podemos atender su llamada, por favor envienos un audio o un mensaje con su consulta'); ; });

thank you for the reply. but I'm using the open-wa webhook method to get messages to my system. npx @open-wa/wa-automate -w 'https://my.domain.com/7a00ac21-60f2-411e-a571-515b37b2025a' like this. i trying to find any parameter to handle "Incoming Call".. or is there any place to input that code.?

smashah commented 3 years ago

@malakaisbest If I'm understanding you correctly, it looks like you need some sort of automatic call response message - where you can set a flag with a default message to send to a number that is trying to call you - which is not a feature yet, but it can be.

Would something like this work for you?

> npx @open-wa/wa-automate -w 'https://my.domain.com/7a00ac21-60f2-411e-a571-515b37b2025a' --on-call "Please do not call this number"
malakaisbest commented 3 years ago

yes absolutely.

smashah commented 3 years ago

@malakaisbest great idea. I'll implement that now.

smashah commented 3 years ago

@github-actions run

⚡ Release! ⚡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci minor`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 3 years ago

Changelog

🚀 Release 4.3.0 (2021-06-10)

smashah commented 3 years ago

@malakaisbest

Please update your local npx cache and try it out!

> npm i @open-wa/wa-automate@latest
> npx @open-wa/wa-automate -w 'https://my.domain.com/7a00ac21-60f2-411e-a571-515b37b2025a' --on-call "Please do not call this number"
malakaisbest commented 3 years ago

@malakaisbest

Please update your local npx cache and try it out!

> npm i @open-wa/wa-automate@latest
> npx @open-wa/wa-automate -w 'https://my.domain.com/7a00ac21-60f2-411e-a571-515b37b2025a' --on-call "Please do not call this number"

I updated it.and it's working fine.. thank you very much :D :D :100:

just idea ~~ if there is any way to decline the call.it will be a good feature...

smashah commented 3 years ago

@malakaisbest Please update your local npx cache and try it out!

> npm i @open-wa/wa-automate@latest
> npx @open-wa/wa-automate -w 'https://my.domain.com/7a00ac21-60f2-411e-a571-515b37b2025a' --on-call "Please do not call this number"

I updated it.and it's working fine.. thank you very much :D :D 💯

just idea ~~ if there is any way to decline the call.it will be a good feature...

Yes. That's the reason this issue is opened actually.

smashah commented 3 years ago

@github-actions run

⚡ Release! ⚡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci minor`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 3 years ago

Changelog

🚀 Release 4.4.0 (2021-06-10)

smashah commented 3 years ago

@malakaisbest

You can now try out local call auto-reject as part of the Insider's Program. Please note, this will automatically reject the call from the host account device. The call from the initiator will continue to ring as if your host account device is offline. As of yet, there is nothing that can be done to remedy this.

Usage:


...
    //just reject the call on the host account device
    await client.autoReject()

    //Reject the call and send a message to the call-initiating account.
    await client.autoReject("Please do not call this number") 

    //If you have an insider's key both will return true, else false.

...

CLI:

> npx @open-wa/wa-automate ... --auto-reject --on-call "Please do not call this number" 

Everybody in this issue above this comment will be getting a free-for-life Insider's Program license key, please DM me on discord to redeem.

For anyone else, please follow the instructions here: https://docs.openwa.dev/pages/The%20Client/licensed-features.html#keys

malakaisbest commented 3 years ago

@malakaisbest

You can now try out local call auto-reject as part of the Insider's Program. Please note, this will automatically reject the call from the host account device. The call from the initiator will continue to ring as if your host account device is offline. As of yet, there is nothing that can be done to remedy this.

Usage:

...
  //just reject the call on the host account device
  await client.autoReject()

  //Reject the call and send a message to the call-initiating account.
  await client.autoReject("Please do not call this number") 

  //If you have an insider's key both will return true, else false.

...

CLI:

> npx @open-wa/wa-automate ... --auto-reject --on-call "Please do not call this number" 

Everybody in this issue above this comment will be getting a free-for-life Insider's Program license key, please DM me on discord to redeem.

For anyone else, please follow the instructions here: https://docs.openwa.dev/pages/The%20Client/licensed-features.html#keys

@smashah thanks for the call auto-reject function. I updated to the 4.4.0 version. but still this function not working for me. The caller and receiver ringing without auto rejecting the call. how can I fix this?

smashah commented 3 years ago

@malakaisbest you need a license to use this feature. Please click on the discord badge in the readme and DM me on discord