- Viber Bot 1.0+
- Node.js 14+
- MongoDB 4.0+
- Mongoose 5.13+
- Bootstrap 5.1+
- Express.js 4.17+
.
├── app.js
├── package.json
├── package-lock.json
├── README.md
├── .gitignore
├── i18n.config.js
├── idle.js
├── jest.config.js
├── Procfile
├── publicUrl.js
├── scheduler.js
└── .circleci
│ | └── config.yml
└── .github
│ ├── workflows
│ | └── codeql.yml
└── locales
│ ├── bg.json
│ └── en.json
└── src
│ └── api
│ | ├── crypto.api.js
│ | └── users.api.js
│ └── config
│ | ├── bot.config.js
│ | ├── database.config.js
│ | ├── express.config.js
│ | ├── router.config.js
│ | └── settings.config.js
│ └── constants
│ | ├── request.headers.js
│ | ├── request.message.js
│ | ├── request.method.js
│ | ├── request.url.js
│ | └── response.message.js
│ └── controllers
│ | ├── bot.controller.js
│ | ├── consolidator.js
│ | ├── event.controller.js
│ | └── msg.controller.js
│ └── helpers
│ | ├── common.ops.helper.js
│ | └── request.helper.js
│ └── models
│ | ├── bitcoin.model.js
│ | ├── ethereum.model.js
│ | └── user.model.js
│ ├── msgJsonTemplates
│ | ├── keyboard.message.json
│ | ├── rich-media.message.json
│ | └── welcome.message.json
│ ├── services
│ | └── locale.service.js
└── static
│ ├── images
│ └── styles
└── tests
│ ├── mock
│ ├── unit
│ └── integration
└── views
├── home
└── layouts
https://partners.viber.com/account/create-bot-account
Node.JS Bot API => https://developers.viber.com/docs/api/nodejs-bot-api/
Create a file .env in main directory and add this below text
VIBER_ACCESS_TOKEN=Your Viber Access Token Add HERE
MONGODB_URI=Your Mongo DB Connection String Add Here
WEBHOOK_URL=Your Heroku URL like https://yourappname.herokuapp.com
PORT=3000
Install ngrok globally with command
npm install -g ngrok
Clone project with
git clone https://github.com/YavorGrancharov/viber_bot.git
npm install
Then, inside app.js file, replace this block of code:
app.listen(settings.port, async () => {
try {
console.log(`Application running on port: ${settings.port}`);
bot.setWebhook(`${process.env.WEBHOOK_URL}/viber/webhook`);
} catch (error) {
console.log('Can not set webhook on following server.');
console.error(error);
process.exit(1);
}
});
with this one:
app.listen(settings.port, async () => {
try {
const publicUrl = await getPublicUrl();
console.log(`Application running on port: ${settings.port}`);
console.log('publicUrl => ', publicUrl);
bot.setWebhook(`${publicUrl}/viber/webhook`);
} catch (error) {
console.log('Can not set webhook on following server.');
console.error(error);
process.exit(1);
}
});
and run project using commands npm run ngrok and npm run start on two separate terminals
You can see it running on localhost:3000
npm run test