So you want to learn how to build your own Telegram bot with Haskell? Let's get you started!
First of all, clone this repository:
git clone https://github.com/fizruk/lambdaconf-2018-workshop.git
For the rest of this document I assume that you work from the root directory of cloned repository.
For the purpose of this workshop we are going to use the Stack tool to manage our Haskell project and install compiler and dependencies for us.
To install Stack on Un*x operating systems all you need to do is run
curl -sSL https://get.haskellstack.org/ | sh
or
wget -qO- https://get.haskellstack.org/ | sh
On Windows, you can download and install the Windows 64-bit Installer.
Stack manages your GHC installations and you can tell it to install GHC with a simple command:
stack setup
This step will download and install GHC 8.2.2 on your computer.
To build a bot we need a few important dependency libraries installed. To install all dependencies and build demo project run:
stack build
Stack builds dependencies from sources, so this step can take a while first time (up to 20 mins).
To facilitate development and get immediate type checks for your code,
install a lightweight ghcid
tool:
stack install ghcid
You can now run ghcid
and it will perform compilation
and type-checking for you on the fly! Just run it in a separate terminal window:
ghcid
To run a Telegram bot you need to create one first, by asking BotFather — a specialised bot that allows you to create new bots!
Be sure to save your newly created bot token (masked on the screenshot)! You will need it to operate your bot during the workshop.
If you want to discuss things with other workshop attendees or ask questions before/after workshop, feel free to join a dedicated chat room on Gitter.im.
That's it! You're all set up and ready for the workshop :)
Some other things to consider:
- make sure your laptop is charged (or that you have a power cord with you);
- it might be easier for you to test your bot on a smartphone, so make sure you have Telegram installed on your phone.