forked from codigoencasa/builderbot
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(starters): base templates are added for meta
excelente trabajo @vicente1992
- Loading branch information
Showing
10 changed files
with
480 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### CHATBOT Whatsapp | ||
|
||
Este bot es una aplicación que puedes vincular con tu whatsapp y crear flujos para automatizar tareas en tu negocio o procesos repetitivos. | ||
|
||
Este bot contiene un flujo básico en el cual una persona (cliente) escribe **"hola"** y el bot responde: | ||
- Bienvenido a mi tienda | ||
- ¿Como puedo ayudarte? | ||
- Tengo: Zapatos, Bolsos etc.. | ||
|
||
__Iniciar__ | ||
|
||
Los flujos se declaran de atrás para adelante, es decir que si tienes un flujo de este tipo: | ||
|
||
Menu Principal | ||
- SubMenu 1 | ||
- Submenu 1.1 | ||
- Submenu 2 | ||
- Submenu 2.1 | ||
|
||
Primero se declaran los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal. | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
__¿Tienes problemas?:__ [Abrir Issue](https://github.com/codigoencasa/bot-whatsapp/issues/new/choose) | ||
|
||
------ | ||
> ¿Quieres se parte de este proyecto? | ||
> - [Discord](https://link.codigoencasa.com/DISCORD) | ||
> - [Twitter](https://twitter.com/leifermendez) | ||
> - [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR) | ||
> - [Telegram](https://t.me/leifermendez) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const { | ||
createBot, | ||
createProvider, | ||
createFlow, | ||
addKeyword, | ||
addChild, | ||
} = require('@bot-whatsapp/bot') | ||
|
||
const MetaProvider = require('@bot-whatsapp/provider/meta') | ||
const JsonFileAdapter = require('@bot-whatsapp/database/json') | ||
|
||
/** | ||
* Aqui declaramos los flujos hijos, los flujos se declaran de atras para adelante, es decir que si tienes un flujo de este tipo: | ||
* | ||
* Menu Principal | ||
* - SubMenu 1 | ||
* - Submenu 1.1 | ||
* - Submenu 2 | ||
* - Submenu 2.1 | ||
* | ||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal. | ||
*/ | ||
|
||
const flowBolsos2 = addKeyword(['bolsos2', '2']) | ||
.addAnswer('🤯 *MUCHOS* bolsos ...') | ||
.addAnswer('y mas bolsos... bla bla') | ||
|
||
const flowZapatos2 = addKeyword(['zapatos2', '2']) | ||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.') | ||
.addAnswer('y algunas otras cosas.') | ||
|
||
const flowZapatos = addKeyword(['1', 'zapatos', 'ZAPATOS']) | ||
.addAnswer('🤯 Veo que elegiste zapatos') | ||
.addAnswer('Tengo muchos zapatos...bla bla') | ||
.addAnswer( | ||
['Manda:', '*(2) Zapatos2*', 'para mas información'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowZapatos2)] | ||
) | ||
|
||
const flowBolsos = addKeyword(['2', 'bolsos', 'BOLSOS']) | ||
.addAnswer('🙌 Veo que elegiste bolsos') | ||
.addAnswer('Tengo muchos bolsos...bla bla') | ||
.addAnswer( | ||
['Manda:', '*(2) Bolsos2*', 'para mas información.'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowBolsos2)] | ||
) | ||
|
||
/** | ||
* Declarando flujo principal | ||
*/ | ||
|
||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo']) | ||
.addAnswer(['Hola, bienvenido a mi tienda', '¿Como puedo ayudarte?']) | ||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc ...']) | ||
.addAnswer( | ||
['Para continuar escribe:', '*(1) Zapatos*', '*(2) Bolsos*'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowBolsos), ...addChild(flowZapatos)] | ||
) | ||
|
||
const main = async () => { | ||
const adapterDB = new JsonFileAdapter() | ||
const adapterFlow = createFlow([flowPrincipal]) | ||
|
||
const adapterProvider = createProvider(MetaProvider, { | ||
jwtToken: 'jwtToken', | ||
numberId: 'numberId', | ||
verifyToken: 'verifyToken', | ||
}) | ||
|
||
createBot({ | ||
flow: adapterFlow, | ||
provider: adapterProvider, | ||
database: adapterDB, | ||
}) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "bot-whatsapp-base-meta-json", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"pre-copy": "cd .. && yarn run copy.lib base-meta-json", | ||
"start": "node app.js" | ||
}, | ||
"keywords": [], | ||
"dependencies": { | ||
"body-parser": "^1.20.1", | ||
"polka": "^0.5.2", | ||
"@bot-whatsapp/bot": "latest", | ||
"@bot-whatsapp/cli": "latest", | ||
"@bot-whatsapp/database": "latest", | ||
"@bot-whatsapp/provider": "latest", | ||
"axios": "^1.2.1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### CHATBOT Whatsapp | ||
|
||
Este bot es una aplicación que puedes vincular con tu whatsapp y crear flujos para automatizar tareas en tu negocio o procesos repetitivos. | ||
|
||
Este bot contiene un flujo básico en el cual una persona (cliente) escribe **"hola"** y el bot responde: | ||
- Bienvenido a mi tienda | ||
- ¿Como puedo ayudarte? | ||
- Tengo: Zapatos, Bolsos etc.. | ||
|
||
__Iniciar__ | ||
|
||
Los flujos se declaran de atrás para adelante, es decir que si tienes un flujo de este tipo: | ||
|
||
Menu Principal | ||
- SubMenu 1 | ||
- Submenu 1.1 | ||
- Submenu 2 | ||
- Submenu 2.1 | ||
|
||
Primero se declaran los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal. | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
__¿Tienes problemas?:__ [Abrir Issue](https://github.com/codigoencasa/bot-whatsapp/issues/new/choose) | ||
|
||
------ | ||
> ¿Quieres se parte de este proyecto? | ||
> - [Discord](https://link.codigoencasa.com/DISCORD) | ||
> - [Twitter](https://twitter.com/leifermendez) | ||
> - [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR) | ||
> - [Telegram](https://t.me/leifermendez) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
const { | ||
createBot, | ||
createProvider, | ||
createFlow, | ||
addKeyword, | ||
addChild, | ||
} = require('@bot-whatsapp/bot') | ||
|
||
const MetaProvider = require('@bot-whatsapp/provider/meta') | ||
const MongoAdapter = require('@bot-whatsapp/database/mongo') | ||
|
||
/** | ||
* Declaramos las conexiones de Mongo | ||
*/ | ||
|
||
const MONGO_DB_URI = 'mongodb://0.0.0.0:27017' | ||
const MONGO_DB_NAME = 'db_bot' | ||
|
||
/** | ||
* Aqui declaramos los flujos hijos, los flujos se declaran de atras para adelante, es decir que si tienes un flujo de este tipo: | ||
* | ||
* Menu Principal | ||
* - SubMenu 1 | ||
* - Submenu 1.1 | ||
* - Submenu 2 | ||
* - Submenu 2.1 | ||
* | ||
* Primero declaras los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal. | ||
*/ | ||
|
||
const flowBolsos2 = addKeyword(['bolsos2', '2']) | ||
.addAnswer('🤯 *MUCHOS* bolsos ...') | ||
.addAnswer('y mas bolsos... bla bla') | ||
|
||
const flowZapatos2 = addKeyword(['zapatos2', '2']) | ||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.') | ||
.addAnswer('y algunas otras cosas.') | ||
|
||
const flowZapatos = addKeyword(['1', 'zapatos', 'ZAPATOS']) | ||
.addAnswer('🤯 Veo que elegiste zapatos') | ||
.addAnswer('Tengo muchos zapatos...bla bla') | ||
.addAnswer( | ||
['Manda:', '*(2) Zapatos2*', 'para mas información'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowZapatos2)] | ||
) | ||
|
||
const flowBolsos = addKeyword(['2', 'bolsos', 'BOLSOS']) | ||
.addAnswer('🙌 Veo que elegiste bolsos') | ||
.addAnswer('Tengo muchos bolsos...bla bla') | ||
.addAnswer( | ||
['Manda:', '*(2) Bolsos2*', 'para mas información.'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowBolsos2)] | ||
) | ||
|
||
/** | ||
* Declarando flujo principal | ||
*/ | ||
|
||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo']) | ||
.addAnswer(['Hola, bienvenido a mi tienda', '¿Como puedo ayudarte?']) | ||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc ...']) | ||
.addAnswer( | ||
['Para continuar escribe:', '*(1) Zapatos*', '*(2) Bolsos*'], | ||
{ capture: true }, | ||
(ctx) => { | ||
console.log('Aqui puedes ver más info del usuario...') | ||
console.log('Puedes enviar un mail, hook, etc..') | ||
console.log(ctx) | ||
}, | ||
[...addChild(flowBolsos), ...addChild(flowZapatos)] | ||
) | ||
|
||
const main = async () => { | ||
const adapterDB = new MongoAdapter({ | ||
dbUri: MONGO_DB_URI, | ||
dbName: MONGO_DB_NAME, | ||
}) | ||
|
||
const adapterFlow = createFlow([flowPrincipal]) | ||
|
||
const adapterProvider = createProvider(MetaProvider, { | ||
jwtToken: 'jwtToken', | ||
numberId: 'numberId', | ||
verifyToken: 'verifyToken', | ||
}) | ||
|
||
createBot({ | ||
flow: adapterFlow, | ||
provider: adapterProvider, | ||
database: adapterDB, | ||
}) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "bot-whatsapp-base-meta-mongo", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"pre-copy": "cd .. && yarn run copy.lib base-meta-mongo", | ||
"start": "node app.js" | ||
}, | ||
"keywords": [], | ||
"dependencies": { | ||
"body-parser": "^1.20.1", | ||
"polka": "^0.5.2", | ||
"@bot-whatsapp/bot": "latest", | ||
"@bot-whatsapp/cli": "latest", | ||
"@bot-whatsapp/database": "latest", | ||
"@bot-whatsapp/provider": "latest", | ||
"axios": "^1.2.1", | ||
"mongodb": "^4.12.1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### CHATBOT Whatsapp | ||
|
||
Este bot es una aplicación que puedes vincular con tu whatsapp y crear flujos para automatizar tareas en tu negocio o procesos repetitivos. | ||
|
||
Este bot contiene un flujo básico en el cual una persona (cliente) escribe **"hola"** y el bot responde: | ||
- Bienvenido a mi tienda | ||
- ¿Como puedo ayudarte? | ||
- Tengo: Zapatos, Bolsos etc.. | ||
|
||
__Iniciar__ | ||
|
||
Los flujos se declaran de atrás para adelante, es decir que si tienes un flujo de este tipo: | ||
|
||
Menu Principal | ||
- SubMenu 1 | ||
- Submenu 1.1 | ||
- Submenu 2 | ||
- Submenu 2.1 | ||
|
||
Primero se declaran los submenus 1.1 y 2.1, luego el 1 y 2 y al final el principal. | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
__¿Tienes problemas?:__ [Abrir Issue](https://github.com/codigoencasa/bot-whatsapp/issues/new/choose) | ||
|
||
------ | ||
> ¿Quieres se parte de este proyecto? | ||
> - [Discord](https://link.codigoencasa.com/DISCORD) | ||
> - [Twitter](https://twitter.com/leifermendez) | ||
> - [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR) | ||
> - [Telegram](https://t.me/leifermendez) |
Oops, something went wrong.