-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Added receiving messages documentation
- Loading branch information
1 parent
0e15c42
commit 4b82687
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Receiving Messages | ||
|
||
To receive messages, you can use the code below | ||
|
||
```javascript | ||
// Supports ES6 | ||
// import { create, Whatsapp } from '@wppconnect-team/wppconnect'; | ||
const wppconnect = require('@wppconnect-team/wppconnect'); | ||
|
||
wppconnect | ||
.create() | ||
.then((client) => start(client)) | ||
.catch((error) => console.log(error)); | ||
|
||
function start(client) { | ||
client.onMessage((message) => { | ||
if (message.body === 'Hello') { | ||
client | ||
.sendText(message.from, 'Hello, how I may help you?') | ||
.then((result) => { | ||
console.log('Result: ', result); //return object success | ||
}) | ||
.catch((erro) => { | ||
console.error('Error when sending: ', erro); //return object error | ||
}); | ||
} | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters