Previous configurations

First of all, dependencies. Add to mix.exs this two things:

In the deps/0 function {:telex, git: “ https://github.com/rockneurotiko/telex.git ", tag: “0.4.0”}

function In the application/0 function add to the list mod: {NiceBot, []}

Here is the mix.exs file:

Remember to add a comma before mod: {NiceBot, []}

Now for the config, we’ll need to identify our bot with a token, you can obtain a bot token from BotFather, using this guide.

Once we have our amazing token we’ll open config/config.exs and write at the end:

config :nice_bot,

token: "591018465:AAEhWJq4ESZbAqLBWzhv98ikUCb5ik2Lk34"

Once again here is our config/config.exs (I like Carbon :D)

Fake token BTW

Programming part ❤

We’re going to open lib/nice_bot.ex and erase everything inside except the definition of the module.

This module is going to be our Application, so we need to see which childs does the application need and the options the Supervisor is going to use, this would be the skeleton:

First of all we need to import Supervisor.Spec to use supervisor/2 function. After that we’ll specify two children:

Telex (in order for all this to work)

NiceBot.Bot (we’ll see it later)

We are going to set fancy logs so we know if the bot is up and running. The result would be this file:

As you can see we take the token from the config/config.exs file with Telex.Config.get/2