Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekaputra07/telegram-bot
Telegram Bot boilerplate in Elixir
https://github.com/ekaputra07/telegram-bot
elixir-lang telegram-bot
Last synced: 5 days ago
JSON representation
Telegram Bot boilerplate in Elixir
- Host: GitHub
- URL: https://github.com/ekaputra07/telegram-bot
- Owner: ekaputra07
- License: mit
- Created: 2023-03-05T07:35:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-05T14:02:26.000Z (about 1 year ago)
- Last Synced: 2023-11-05T15:23:14.189Z (about 1 year ago)
- Topics: elixir-lang, telegram-bot
- Language: Elixir
- Homepage: https://t.me/ElixirDemoBot
- Size: 35.2 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# telegram-bot
A starting point to create your own Telegram bot with Elixir.
### 👉 Development
A couple of helper scripts available under `scripts/` to ease development on your local machine.
Working on the bot locally:
1. Register your Bot using Telegram's `@BotFather` and get the token.
1. Start [**ngrok**](https://ngrok.com/) on port 8080 by running `ngrok http 8080` command. Ngrok will act as reverse proxy so Telegram could access your bot from the internet.
1. Create `.env` file and fill with environment variables that we'll pass to the app:```
BOT_HOST=.ngrok.io
BOT_TOKEN=
```
1. Start the bot with our helper script: `./script/dev`. It will start an _IEx_ shell (`iex -S mix`)
1. Start developing.You'll want to update the `lib/bot.ex` to suit your need (handle messages or making replies).
### 👉 Deployment
It's up to you on how and where you want to deploy the bot. Here's how I deploy it to [Fly.io](https://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:
1. Run `fly launch` and follow the steps (you only need to do this once and `fly.toml` file will be generated - see `fly.toml.example`)
1. Set bot environment variable as secrets:```
fly secrets set BOT_HOST=.fly.dev
fly secrets set BOT_TOKEN=
```
1. Run `fly deploy` to proceed with deployment.Once finished, you will have the bot up and running and ready to accept messages.
### 👉 Demo bot
Open this link [t.me/ElixirDemoBot](https://t.me/ElixirDemoBot) and send `/ping` message, it will reply with `pong!`