This guide will walk you step-by-step through deploying an example chat bot (which can be found in the u32i64/vk-chat-bot-example repository) for a community using Heroku.
- Visit signup.heroku.com and create an account there.
- After completing the registration process, visit your Heroku Dashboard.
- Create a new app with any name that is available.
- Visit vk.com/groups, click
Create community
, and fill in the details:
- In your community, go to
Manage
. - Go to
Messages
tab, and enable community messages. - In
Messages
->Bot settings
enableBot abilities
, and then enableAdd start button
. - Go to
Settings
->API usage
. - Create a new access token by clicking
Create token
. Make sure to check this box:
- Save your new token somewhere.
- Now switch to the
Callback API
->Server settings
tab. - Set the API version to
5.80
. - In the
Secret key
field, enter your own random combination of characters. - Click
Save
below that field. - Go back to
Server settings
tab and enter in theURL
field: https://your-app-name
.herokuapp.com/ (Replaceyour-app-name
with the name you specified when creating a new Heroku app in step 1). - Don't press
Confirm
and don't close this page yet.
- Open the
Settings
tab in your Heroku app, clickReveal Config Vars
, and add variables, as follows:
Variable name | Description | Example value |
---|---|---|
VK_API_KEY |
The token you saved earlier into somewhere | - |
SECRET |
Secret key | r4nd0m_53cr37_k3y |
GROUP_ID |
Number that comes after "group_id": |
123456789 |
CONFIRMATION_TOKEN |
String that comes after String to be returned: |
f1234567 |
CMD_PREFIX |
Any command prefix | / |
- Make sure you have git and Heroku CLI installed.
- Open up terminal (console), and execute the following commands (assuming your project name on Heroku is
some-random-chat-bot
):
# Clone the example repository
git clone https://github.com/u32i64/vk-chat-bot-example.git
# Go inside the newly-created folder
cd vk-chat-bot-example
# Log in to Heroku
heroku login
# Add the heroku remote
heroku git:remote -a some-random-chat-bot
# Finally, push the bot to Heroku
git push -u heroku master
- Go to your app's logs (in Heroku app dashboard ->
More
->View logs
) - If you see a log message like the one below, then the bot has launched successfully:
bot info Server is listening on port 12345
If something is not working, feel free to open an issue on GitHub.
- Now go back to VK's Callback API settings, and press the
Confirm
button. - Also, in the
Event types
tab, check the following boxes:
- Congratulations, you have just made your own VK chat bot!