├── 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 |

WiseBOT

5 |

O WiseBOT é um chatbot que utiliza o Flowise para se comunicar e responder perguntas dos usuários.

6 |

Updates

7 |
8 |

Roadmap

9 |

Versão 1.0 - DONE

10 |
11 |

Versão 1.1 - DONE

12 |
13 |

Versão 2.0 - WIP

14 |
15 |

Versão 3.0

16 |
17 |

Versão 4.0

18 |
19 |

Como executar o WiseBOT

20 |
  1. Clone este repositório.
21 |
git clone https://github.com/Mpiffer/whatsapp-flowise.git 22 |
23 |
  1. Instale as dependências.
24 |
cd wisebot 25 | npm install 26 |
27 |
  1. Configure as informações necessárias.
28 |

Abra o arquivo index.js e insira as credenciais do Flowise e o token de autorização.

29 |
javascript
32 |
  1. Execute o WiseBOT.
33 |
node index.js 34 |
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 | 45 | -------------------------------------------------------------------------------- /en-README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |

WiseBOT

4 |

WiseBOT is a chatbot that utilizes Flowise to communicate and answer user questions.

5 |

Updates

6 |
7 |

Roadmap

8 |

Version 1.0

9 |
10 |

Version 1.1

11 |
12 |

Version 2.0 - WIP

13 |
14 |

Version 3.0

15 |
16 |

Version 4.0

17 |
18 |

How to run the WiseBOT

19 |
  1. Clone este repositório.
20 |
git clone https://github.com/Mpiffer/whatsapp-flowise.git 21 |
22 |
  1. Instale as dependências.
23 |
cd wisebot 24 | npm install 25 |
26 |
  1. Configure.
27 |

Abra o arquivo index.js e insira as credenciais do Flowise e o token de autorização.

28 |
javascript
31 |
  1. Run the WiseBOT.
32 |
node index.js 33 |
34 |

Certifique-se de configurar corretamente as credenciais e outros parâmetros necessários antes de executar o WiseBOT.

35 |

Contribuição

36 |

Contribuições são bem-vindas! Sinta-se à vontade para enviar pull requests com melhorias, correções de bugs ou novos recursos.

37 |

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.

38 |

Licença

39 |

Este projeto está licenciado sob a licença MIT. Leia o arquivo LICENSE para obter mais detalhes.

40 |

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 | --------------------------------------------------------------------------------