Viber recently opened up an interface for chat-bot automation. Claudia Bot Builder, since version 2.5.0, allows you to easily create and deploy chat bots for the new Viber platform. In this set-by-step tutorial, you’ll learn how to create a Viber chat-bot and deploy it to AWS Lambda.
Prerequisites
- Node.js 8.10 with NPM (Node 6 is also supported by Lambda)
- An AWS account with the permissions to create Lambda functions, API Gateway end-points and IAM roles.
- Claudia.js 4.0.0 or later
If you’re completely new to using Claudia.js, check out Installing and configuring Claudia.js for information on how to set up access credentials.
Creating the Viber Public Account
To create a Viber bot, you will need to create a Public Account (PA). The PA represents an account of a company, celebrity, person or product. After your Public Account is approved, you will be able to get the authentication token from the Public Account. You’ll need this later to configure the bot.
Creating a Viber bot
First, create an empty folder, and a new NPM project inside it. Just make sure to give it a descriptive name:
Add the claudia-bot-builder
library as a project dependency:
Let’s first create a very simple bot, just to check that everything is configured correctly. Create a file called bot.js
with the following content:
This bot will just reply back with the same message it received. Later on, we’ll modify it to do something more interesting.
Deploying your Viber bot
You can now deploy the bot to AWS:
The api-module
parameter is the name of your JavaScript module (if you saved the code as bot.js
, this will be just bot
).
While deploying, Claudia will ask for your Viber Public Account Access Token. It will then automatically create the right web hooks for the Viber bot platform. In a few moments, your bot will be online and you will be able to chat to it using Viber.
And that’s it.