Skip to content

Commit

Permalink
docs: Added receiving messages documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Mar 29, 2021
1 parent 0e15c42 commit 4b82687
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/getting-started/receiving-messages.md
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
});
}
});
}
```
4 changes: 4 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"title": "Creating a Client",
"source": "./docs/getting-started/creating-client.md"
},
{
"title": "Receiving Messages",
"source": "./docs/getting-started/receiving-messages.md"
},
{
"title": "Configuring the logger",
"source": "./docs/getting-started/configuring-logger.md"
Expand Down

0 comments on commit 4b82687

Please sign in to comment.