danielcardeenas / sulla

👩🏻‍🔬 Javascript Whatsapp api library for chatbots
MIT License
1.27k stars 271 forks source link

Architecture help #371

Open alangarbo opened 4 years ago

alangarbo commented 4 years ago

I have an architectural question about how to use this library on a system that I am developing. The solution has to be permanently waiting for new messages and do something. With the following code I can start the service and wait for messages:

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!'); } }); }

My question is how can I listen to new messages and also be able to send messages to a contact or a new number. I dont want to to replay a incomming message, I need the application send one ( send a notification for some events to the customers). I know how is the code to send text and multimedia messages My question is how to put all together, the architecture of the solution.

I can do a script that checks for new messages in a database or a queque and send it using sulla, but there is already another process that is waiting for new messages.

I think in use Express to get a endpoint where the app can use as an API to send mensage , but I dont know how to do the startup the sulla client once to be use for every request and also to the same client lisening for new message.

Can someone help me? Thanks

joedutra commented 4 years ago

the repository is deprecated use

Install npm i @s2click/venom https://github.com/s2click/venom

vasani-arpit commented 4 years ago

@alangarbo So, every time a new message comes from any one you want to send a completely unrelated message to completely unrelated person which is in your contact. Is it something like that?