I was looking around a different projects that integrate with ollama and saw one about a telgram bot. I rarely use telegram but it looks like fun, so lets go through and plug it in.

Setup the telegram bot.

https://core.telegram.org/bots#how-do-i-create-a-bot to create a bot. The short answer is you need to message the botfather.

Say /newbot.

Give it a name. Give it an account name. Save the API key. Save that stuff for later.

Find your user id

Go to the userinfobot and say /start to get your info.

Download ruecat/ollama-telegram

1
2
3
4
5
  # Or some other directory
  cd $(mktemp -d)

  git clone https://github.com/ruecat/ollama-telegram
  cd ollama-telegram

Set it up

1
2
3
4
  python3 -m venv .venv
  source .venv/bin/activate

  pip install -r requirements.txt

Edit the config

TOKENTelegram token
ADMIN_IDSYour user id
USER_IDSYour user id
INITMODELllama3.1
OLLAMA_BASE_URLlocalhost

Then

1
2
  cd bot
  python3 run.py

Conclusion

I had no idea it was so easy to create telegram bots! That's super fun.