├── LICENSE ├── README.md ├── en-README.md ├── index.js ├── indextest.js └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mpiffer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | EN README https://github.com/Mpiffer/whatsapp-flowise/blob/main/en-README.md 4 |O WiseBOT é um chatbot que utiliza o Flowise para se comunicar e responder perguntas dos usuários.
@c.us
. Agora os números devem ser adicionados no formato "5511912345678@c.us".git clone https://github.com/Mpiffer/whatsapp-flowise.git 22 |
cd wisebot 25 | npm install 26 |
Abra o arquivo index.js
e insira as credenciais do Flowise e o token de autorização.
32 |javascript33 |
- Execute o WiseBOT.
35 |node index.js 34 |
36 |Certifique-se de configurar corretamente as credenciais e outros parâmetros necessários antes de executar o WiseBOT.
37 |Contribuição
38 |Contribuições são bem-vindas! Sinta-se à vontade para enviar pull requests com melhorias, correções de bugs ou novos recursos.
39 |Antes de enviar uma solicitação de pull, verifique se o código está de acordo com as diretrizes de estilo e passe por testes adequados.
40 |Licença
41 |Este projeto está licenciado sob a licença MIT. Leia o arquivo LICENSE para obter mais detalhes.
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /en-README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |4 |WiseBOT
5 |WiseBOT is a chatbot that utilizes Flowise to communicate and answer user questions.
6 |Updates
7 |
- Fixed the format of the numbers in the whitelist to include the
@c.us
suffix. Numbers should now be added in the format "5511993589393@c.us".- Improved logging for message flow debugging.
8 |Roadmap
9 |Version 1.0
10 |
- Integration with Flowise to process questions and obtain answers.- DONE
- Authorization functionality based on a whitelist of numbers.- DONE
- Respond to the message "Hi" with a friendly greeting.- DONE
- Handle general questions and provide relevant answers.- DONE
11 |Version 1.1
12 |
- Add support for more complex questions with context analysis.- DONE
- Implement learning capabilities to improve responses over time.- DONE
- Integration with external APIs to retrieve additional information.- DONE
- Enhance user interface and user experience.- DONE
13 |Version 2.0 - WIP
14 |
- Integration with additional chat platforms, such as Facebook Messenger, etc. - WIP
- Increase language support coverage.- DONE
- Add advanced natural language processing features.- DONE
- Incorporate machine learning to improve question understanding.- DONE
15 |Version 3.0
16 |
- Implement support for voice-enabled chatbots.
- Create an administration interface to manage the chatbot and view metrics.
- Implement advanced customization and configuration features.
- Enhance scalability and performance of the chatbot.
17 |Version 4.0
18 |
- Add support for chatbots on social media platforms like Twitter and Instagram.
- Incorporate sentiment analysis to respond based on the user's emotional tone.
- Develop real-time natural language processing capabilities.
- Integrate with popular virtual assistants like Siri, Google Assistant, Alexa, etc.
19 |How to run the WiseBOT
20 |
- Clone este repositório.
22 |git clone https://github.com/Mpiffer/whatsapp-flowise.git 21 |
23 |
- Instale as dependências.
26 |cd wisebot 24 | npm install 25 |
27 |
- Configure.
28 |Abra o arquivo
index.js
e insira as credenciais do Flowise e o token de autorização.31 |javascript32 |
- Run the WiseBOT.
34 |node index.js 33 |
35 |Certifique-se de configurar corretamente as credenciais e outros parâmetros necessários antes de executar o WiseBOT.
36 |Contribuição
37 |Contribuições são bem-vindas! Sinta-se à vontade para enviar pull requests com melhorias, correções de bugs ou novos recursos.
38 |Antes de enviar uma solicitação de pull, verifique se o código está de acordo com as diretrizes de estilo e passe por testes adequados.
39 |Licença
40 |Este projeto está licenciado sob a licença MIT. Leia o arquivo LICENSE para obter mais detalhes.
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const wa = require('@open-wa/wa-automate'); 2 | const axios = require('axios'); 3 | 4 | // Números permitidos na lista branca (no formato 5511993589393@c.us) 5 | const whitelistedNumbers = [ 6 | '551234567890@c.us', 7 | '551111111111@c.us', 8 | '5511912345678@c.us' // Adicione seu número aqui 9 | ]; 10 | 11 | wa.create({ 12 | sessionId: "COVID_HELPER", 13 | multiDevice: true, 14 | authTimeout: 60, 15 | blockCrashLogs: true, 16 | disableSpins: true, 17 | headless: true, 18 | hostNotificationLang: 'PT_BR', 19 | logConsole: false, 20 | popup: true, 21 | qrTimeout: 0, 22 | }).then(client => start(client)); 23 | 24 | function start(client) { 25 | // Evento de recebimento de mensagem 26 | client.onMessage(async message => { 27 | console.log('Mensagem recebida:', message.body); 28 | console.log('Remetente:', message.from); 29 | 30 | // Verificar se o número está na lista branca 31 | if (isNumberWhitelisted(message.from)) { 32 | console.log('Número autorizado.'); 33 | 34 | if (message.body === 'Hi') { 35 | await client.sendText(message.from, '👋 Olá!'); 36 | console.log('Resposta enviada: 👋 Olá!'); 37 | } else { 38 | // Enviar a pergunta para o endpoint da API 39 | const question = message.body; 40 | const token = 'pOZiOWTf4aDiBD2PinQyX9nEjXstIPeGecqUx2onR/E='; // Substitua pelo seu token de autorização 41 | 42 | try { 43 | const response = await axios.post('http://192.168.15.8:3000/api/v1/prediction/2f3522c3-1e9f-4f2e-a411-f34303e98cd2', { 44 | question: question 45 | }, { 46 | headers: { 47 | Authorization: `Bearer ${token}` 48 | } 49 | }); 50 | 51 | const answer = response.data; // Obter a resposta da API 52 | 53 | await client.sendText(message.from, answer); 54 | console.log('Resposta enviada:', answer); 55 | } catch (error) { 56 | console.error('Erro na solicitação à API:', error); 57 | await client.sendText(message.from, 'Desculpe, ocorreu um erro ao processar sua pergunta.'); 58 | console.log('Resposta de erro enviada: Desculpe, ocorreu um erro ao processar sua pergunta.'); 59 | } 60 | } 61 | } else { 62 | console.log('Número não autorizado.'); 63 | await client.sendText(message.from, 'Desculpe, você não está autorizado a interagir com este chatbot.'); 64 | console.log('Resposta de autorização negada enviada.'); 65 | } 66 | }); 67 | } 68 | 69 | function isNumberWhitelisted(number) { 70 | // Verificar se o número está presente na lista branca 71 | return whitelistedNumbers.some(whitelistedNumber => whitelistedNumber === number); 72 | } 73 | -------------------------------------------------------------------------------- /indextest.js: -------------------------------------------------------------------------------- 1 | const wa = require('@open-wa/wa-automate'); 2 | const axios = require('axios'); 3 | 4 | wa.create({ 5 | sessionId: "COVID_HELPER", 6 | multiDevice: true, 7 | authTimeout: 60, 8 | blockCrashLogs: true, 9 | disableSpins: true, 10 | headless: true, 11 | hostNotificationLang: 'PT_BR', 12 | logConsole: false, 13 | popup: true, 14 | qrTimeout: 0, 15 | }).then(client => start(client)); 16 | 17 | function start(client) { 18 | client.onMessage(async message => { 19 | if (message.body === 'Hi') { 20 | await client.sendText(message.from, '👋 Olá!'); 21 | } else { 22 | // Enviar a pergunta para o endpoint da API 23 | const question = message.body; 24 | const token = 'pOZiOWTf4aDiBD2PinQyX9nEjXstIPeGecqUx2onR/E='; // Substitua pelo seu token de autorização 25 | 26 | try { 27 | const response = await axios.post('http://192.168.15.8:3000/api/v1/prediction/2f3522c3-1e9f-4f2e-a411-f34303e98cd2', { 28 | question: question 29 | }, { 30 | headers: { 31 | Authorization: `Bearer ${token}` 32 | } 33 | }); 34 | 35 | const answer = response.data; // Obter a resposta da API 36 | 37 | await client.sendText(message.from, answer); 38 | } catch (error) { 39 | console.error(error); 40 | await client.sendText(message.from, 'Desculpe, ocorreu um erro ao processar sua pergunta.'); 41 | } 42 | } 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "whatsapp-flowise", 3 | "version": "1.0.0", 4 | "description": "is it possible to send messages to whatsapp using flowise", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@open-wa/wa-automate": "^1.12.1", 14 | "axios": "^0.24.0", 15 | "better-sqlite3": "^7.5.0" 16 | } 17 | } 18 | 19 | --------------------------------------------------------------------------------