Dibuat untuk memberikan sedikit sentuhan AI kepada Group Telegram UpKoding. Dengan bot ini saya (admin) bisa memerintahkan bot untuk membantu menjawab pertanyaan anggota apabila kebetulan saya tidak memiliki kompetensi di bidang yang ditanyakan.
Anggota group juga bisa berinteraksi langsung dengan bot secara privat, hampir sama seperti chatting dengan ChatGPT tetapi dengan bot telegram.
Powered by https://github.com/ekaputra07/telegram-bot a starting point to create your own Telegram bot with Elixir.
A couple of helper scripts available under scripts/
to ease development on your local machine.
Working on the bot locally:
-
Register your Bot using Telegram's
@BotFather
and get the token. -
Start ngrok on port 8080 by running
ngrok http 8080
command. Ngrok will act as reverse proxy so Telegram could access your bot from the internet. -
Create
.env
file and fill with environment variables that we'll pass to the app:BOT_HOST=<your-ngrok-subdomain-here>.ngrok.io BOT_TOKEN=<your-bot-token-here>
-
Start the bot with our helper script:
./script/dev
. It will start an IEx shell (iex -S mix
) -
Start developing.
You'll want to update the lib/bot.ex
to suit your need (handle messages or making replies).
It's up to you on how and where you want to deploy the bot. Here's how I deploy it to Fly.io as Docker container.
Prerequisites:
- Make sure you have an account at Fly.io
- Make sure you have
fly
CLI installed - Make sure you're logged-in using
fly auth login
Deploy steps:
-
Run
fly launch
and follow the steps (you only need to do this once andfly.toml
file will be generated - seefly.toml.example
) -
Set bot environment variable as secrets:
fly secrets set BOT_HOST=<your-fly-io-appname>.fly.dev fly secrets set BOT_TOKEN=<your-bot-token>
-
Run
fly deploy
to proceed with deployment.
Once finished, you will have the bot up and running and ready to accept messages.
Open this link t.me/ElixirDemoBot and send /ping
message, it will reply with pong!