Content Creators

How to create your own Chat Bot on your LiveEdu channel

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:

var username = 'LCTV_BOT_USERNAME';
var password = 'XMPP_BOT_PASSWORD'; 
var room = 'LCTV_USER_WHERE_BOT_WILL_BE';

module.exports = {
    room: username,
    username: username,
    jid: username + '@livecoding.tv',
    password: password,
    roomJid: room + '@chat.livecoding.tv'
};

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

{
    "plugins": {
        "noifications": true,
        "api-triggers": true
    }
}

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:
module.exports = [{
  types: ['message'],
  regex: /hello/,
  action: function( chat, stanza ) {
        chat.replyTo( stanza.user.username, 'Welcome to the stream!' );
  }
}]

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:
{
   "plugins": {
       "notifications": true,
       "api-triggers": true,
       "lctv-bot-welcome-plugin": true
   },
 }
  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:

{
   "plugins": {
       "notifications": true,
       "api-triggers": true,
       "lctv-bot-welcome-plugin": true
   },
   "lctv-bot-welcome-plugin": {
        "welcome-message": "Welcome to the stream from settings"
    }
}

And then customize the plugin code by using this setting:

const Settings = require('../../utils/Settings');


module.exports = [{
  types: ['message'],
  regex: /hello/,
  action: function( chat, stanza ) {
        chat.replyTo( stanza.user.username, Settings.getSetting("lctv-bot-welcome-plugin","welcome-message"));
  }
}]

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

Dr. Michael J. Garbade

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.

Recent Posts

Highest Stable Coin Yields – (W16 – 2024)

Another week to bring you the top yield platforms for three of the most prominent…

2 weeks ago

LEDU Token OTC Trading

If you hold a large volume of LEDU tokens above 1 million units and wish…

1 month ago

Highest Stable Coin Yields – (W12 – 2024)

It’s another week and like always we have to explore the top yield platforms for…

1 month ago

Binance Auto Invest – the Best Innovation in Crypto since Sliced Bread

At a time where we’re constantly seeking tools and strategies to simplify our crypto investments,…

1 month ago

Highest Stable Coin Yields – March 2024

As we kick off another week, it's time to explore the top yield platforms for…

2 months ago

Education Ecosystem Featured on Business Insider

We're excited to share that Education Ecosystem was recently featured in an article on Business…

2 months ago