Content Creators

How to create your own Chat Bot on your LiveEdu channel

livecoding chat bot

This guide will walk you through the process of setting up your  LiveEdu chat bot and customizing it for your needs.

INSTALL NODE.JS

The base bot we will work with was developed with node.js, so if you don’t have it installed, visit the Node.js official website to download the package for your platform and install it.

We recommend you use the LTS release.

For example, if you are using Windows then download the MSI package and go through the standard setup procedure.

Once the installation has finished, verify it by typing “node -v” in the terminal.

GET BASE BOT

If you are a git user, clone the base bot sources from github with this command:

git clone https://github.com/ArtemiusUA/livecodingtv-bot.git

Or download and unzip the archive:

https://github.com/ArtemiusUA/livecodingtv-bot/archive/master.zip

SETTINGS FOR YOUR  LiveEdu ACCOUNT

Navigate to the “setup” directory in the bot’s directory.

Create a folder named “custom” in the “setup” directory.

Create a “credentials.js” file and “settings.json” file in the “custom” directory.

Find your XMPP password on the LCTV page:

  1. Open your live stream page ( https://www.livecoding.tv/USERNAME ).
  2. Open Dev Tools (“ctrl+shift+i”) and switch to the Elements tab.
  3. Search the HTML content for “password”.
  4. The XMPP password will be a long string in an object containing “jid” and “password”.

Fill in the “credentials.js” file with the following:

Fill in the “settings.json” file with the following

Run “npm install” in terminal, to install dependencies.

Run “node index.js” to start the bot.

If you are on Windows, you will see a firewall prompt to allow network access. Click on the Public Network checkbox and select Allow.

At this point the bot is working and ready to accept standard commands. You can enter the following commands in the chat window to test it:

!status – Returns the user status.

!subject [type subject] – Sets the room‘s subject to {subject}.

!todo – List the current TODOs.

!top [input number] – Displays the top {number} viewers.

CUSTOMIZE BOT’S FUNCTIONALITY

To customize the bot’s functionality for your needs, you can go with plugins. You can find some plugins on github, or create your own.

Let’s go through the plugin development process.

1 . Check if there is a “plugins” directory in the “bots” directory. If not, create it.  

  1. Each plugin lives in its own subdirectory in “plugins”, so you have to create a new directory for your plugin.
  1. All plugins require “index.js” as an entry point. This file is used by the bot to process incoming messages and react to them. Create an “index.js” file in your “plugins” directory.
  1. The “index.js” file must export an array of command objects to incoming messages handlers. Each command is checked with regexp against incoming messages, and when  a match is found, the actions function of a command is invoked. Example:
This plugin will reply “Welcome to the stream!” if someone types “hello” or “hi!”

  1. To enable the plugin, update the bot’s settings file ( “setup/custom/settings.json” ) with your plugin:
  1. All plugins have access to these settings, stored in the “setup” directory. Also, plugins can have their own settings, stored in “settings.json” in the “plugins” directory.

Let’s store the welcome message in  “setup/custom/settings.json”  file:

And then customize the plugin code by using this setting:

For further examples, you can check other bot plugins on github, or get the core commands code.

Avatar
About author

I, Dr. Michael J. Garbade is the co-founder of the Education Ecosystem (aka LiveEdu), ex-Amazon, GE, Rebate Networks, Y-combinator. Python, Django, and DevOps Engineer. Serial Entrepreneur. Experienced in raising venture funding. I speak English and German as mother tongues. I have a Masters in Business Administration and Physics, and a Ph.D. in Venture Capital Financing. Currently, I am the Project Lead on the community project -Nationalcoronalvirus Hotline I write subject matter expert technical and business articles in leading blogs like Opensource.com, Dzone.com, Cybrary, Businessinsider, Entrepreneur.com, TechinAsia, Coindesk, and Cointelegraph. I am a frequent speaker and panelist at tech and blockchain conferences around the globe. I serve as a start-up mentor at Axel Springer Accelerator, NY Edtech Accelerator, Seedstars, and Learnlaunch Accelerator. I love hackathons and often serve as a technical judge on hackathon panels.