You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
424 B
JavaScript
17 lines
424 B
JavaScript
6 months ago
|
const whatsappEvents = require('../emitter');
|
||
|
const { callWebhook } = require('../webhook');
|
||
|
|
||
|
const logger = console;
|
||
|
|
||
|
function setupMessageHandler() {
|
||
|
whatsappEvents.on('message:received', async messageData => {
|
||
|
try {
|
||
|
await callWebhook(messageData);
|
||
|
} catch (error) {
|
||
|
logger.error({ messageData, error }, 'error call webhook');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
module.exports = { setupMessageHandler };
|