
Good afternoon, dear Habravchane! Today I decided to tell you about our experience in creating a bot for Telegram on Node.js with virtually no server development experience and on a voluntary basis. Immediately make a reservation: behind my back a little more than four years of development for iOS, the rest of the team members also had development experience from one to six years in related fields. For most of us, this was the first time that Node.js was used in a relatively large project. How we did it, why we did it, why the freelance exchange and how it differs from the classic models, what problems we had and how we struggled with them - under the cut!
How did it all start?
It so happened that in my free time I advise startups: how to start, where to find investments, why the development cycle is so long, how to pass the code from one contractor to another, and the like. Having gained a sufficient amount of experience, they began to share on social networks, from which a small group (273 people at the time of writing the topic) grew up in a Telegram group; where we flood, communicate, help each other and watch online streaming development.
Somewhere about six months ago, I began to study Node.js for self-development and, quite recently, I wrote a couple of game bots exclusively for our channel. Then the guys pulled up - they wrote a couple more bots (by the way, we put all the bots in open access - be
careful, I’m not vouching for the integrity of your ok ). There are slots, Russian roulette, and the own currency "Helionchiki" is (named after one of the oldfags of our party).
')
By the nature of my profession, I have a list of contacts of proven programmers (iOS, Android, Web) with whom I have already worked and which I occasionally gather into teams to start or support startups of clients who have received funding. Initially, my contact list was on Skype, but today it has completely migrated to Telegram. And so, once again sending job offers to talented programmers, I caught myself thinking: why can't we automate this process? I do it every 2-3 weeks. Here the idea arose to create a bot that does this for us. You throw him a job description, and he immediately gives a list of freelancers in the right category and with the desired hourly rate.
Having slept with the idea, after talking with a couple of customers, having discussed the idea with friends from the warm and lamp-based Telegram chat, it was decided to make an exchange over the weekend, gather a small team and brew a couple of tea bowls. But not here it was - two days turned into four weeks!
Initially, our goal was to make a convenient free freelance stock exchange and then put the code in open access. We made the decision to never monetize the service and maintain it with our own money from breakfast. But hope for normal breakfasts appeared in our hearts when Pavel Durov
announced grants for bots . A week before the official launch, but with an already fully working platform, we wrote
@BotSupport , thereby leaving a request. If anyone is interested, you can read the text of the application:
Push me!#BotPrize
Good morning dear Telegram Bot Support team! We've recently heard about the Telegram. Our bot's handle is @ * bot * We are, what is @ bot * and what are our plans!
If you’re a little bit different, you’ll have to do this. For now, we have 5 weeks. I’ve got some live videos to watch a telegram of more than :)
Node.js can be used. We have a couple of things to do.
So what is @ * bot *? It is a complete telegram-market system:
- After all the spam-like freelancer's offers. In our case, the client chooses who should receive a job offer at freelancers' bios.
- With the freelance system In our case, we’ll send you a list of your choice. After that, you should get a job offer. No need to wait!
- It is pretty much a blockhouse for them. In our case, it can be seen how many people need to be.
- With a classic freelance system In our case, it is your request.
- With the classic freelance system, there is a hyper-proactive monitoring of the situation. In the case of her life, he will receive her job as soon as possible. clients would like to work with him.
- And, the most important thing. Most of the classic freelance services are commercial-oriented: they have membership fees. In our case, we decided to keep the bot completely non-profit. It means that you can use it.
- It’s not a problem. In our case, we’ve been able to make it. This will be a completely open and community-oriented system. We reach the threshold of 1000 registered users. To better support our claims, we are on our monthly basis: github.com/borodutch.
And did I mention this freelance marked is 100% based on Telegram? Or Telegram. No need to login anywhere!
What are our plans for future?
- First, we will fix some minor texts.
- This is a list of the freelance market system. This is a web site for users.
- I am still holding on to the producthunt (I’m not on the way). well - producthunt.com/@nikitakolmogorov), reddit, pikabu and vc.ru Relatively short period in time.
- Improve existing ones.
This is it - our freelance chat bot market in the nutshell. We have used keyboards to enhance the UX; we even have pagination in one of the inline keyboards;)
Why would we like the join contest? Well, it’s not a problem. If you would like to get a little bit of care, it would help. all of them). It is a concept of our philosophy. User-base and support further development.
I like the chat platform! Again, you sooner than later :) In case you like it;)
Thank you for reading our bot. Please have a wonderful day!
So why, say, one more freelance exchange?
It would seem: there is Upwork, FL, a couple of good freelance bots in Telegram - so why do we need another exchange? Somewhere two years ago I would have asked the same question, but recently I switched to the other side of the freelance exchanges: from freelancer to customers. And if you didn’t like the way the exchanges work on the freelancer side, believe me, the picture on the client’s side looks even worse.
Suppose you need to create a website and you are looking for a good contractor - you post an ad for the same Upwork, then what? Hell begins, on which you spend the lion's share of your time: there comes a ton of terrible spam mailings from obscure studios from India. Okay, we screen them out. What to do with the second ton of applications? Oh, there are too many of them - we eliminate everyone with a rating below 4.8 stars. Oh, there are still 130 applications left. Okay, we screen out the portfolio - like or dislike. Oh, again there are around 40 applications. Well, do not worry, I will write everyone a carbon copy of the answers and ask for contact details for communication. Oh, how is it all for a long time. And then also to communicate with everyone - it is also not clear how much it all costs, we should ask everyone.
Is it possible to automate this process? After consulting, we thought up an alternative system of freelance exchanges with several differences from the classical model:
- The client receives a list of the top 10 freelancers as soon as he creates a new job. From this list, the client chooses who to send a job offer to.
- The freelancer only needs to fill out his profile and follow the rating - the proposals will come to the freelancer themselves if the profile is liked by the customers.
- The exchange is absolutely free and forever this will remain. We do not block the communication between the client and the freelancer and do not use clever tricks for making money.
- As soon as we have 1000 active users, we will put the bot code in open access so that everyone can fix the bug or add a function if they want.
By introducing this series of changes and giving the community control over the exchange, we hope to improve the quality of communication between customers and clients, speed up the process of finding a contractor and making a deal. Said - done: the bot works fine with 176 users at the time of this writing.
How did we organize the work?
As a result, we had five programmers without obvious management - you know what this all leads to. Out of habit, we started using Trello - it's free and simple enough - to keep track of bugs and tasks. They threw a simple structure with columns like “To do”, “Working”, “Testing”, “Done”, “Future” and threw the cards between them. So this ugliness looked like:

We could use both JIRA and a BitBucket bug tracker, but it all seemed too big and cumbersome for our relatively small project. Moreover, we don’t really want to linger on BitBucket. As soon as we hit the mark of 1000 users, we move the code to open access on GitHub. In our team, anyone could create a new card with a bug or features, and then, after consulting, we either attached a card to one of us, or transferred the card to the “Future” column - ideas left for the future. Very much, we wanted to launch MVP - we had to cut our Wishlist to the maximum.
We most often consulted precisely in Telegram. Considering that we had a different experience of developing in JavaScript and Node.js, we learned from the mistakes and advice of each other. If someone threw a bad commit into their branch, then we quickly corrected it. By the way, in the beginning we used the nicknames on BitBucket as the name of the branches, but then we switched to the orthodox names of features - it became so much more convenient for us to commit to each other's branches.
What difficulties did we encounter on the way?
Of course, all the pitfalls will not be able to cover, but I will try to tell you about a few particularly outstanding problems that have stalled the development of the bot quite strongly.
1. Creating a website
This problem, rather, appeared due to the fact that we all worked for free and none of us had any motivation other than launching the product. So, the first developer who started a landing page for a bot turned out to be very busy with the main project that paid its bills. Nothing bad happened, we passed the development to another person. Secondly, it happened - we don’t know, because of lack of experience in front-end development, this happened or because of something else, but also did not cope with the task, did not suit us with the result. But now our hero appears from nowhere and makes up a page that was designed by one of the magnificent five programmers from the lamp chat! And everything is great: we are hosted on Github Pages, bugs rule as they arrive, by God, happiness! And our site has earned. Screwing a small server statistics, we got interesting numbers in real time.

And after that, by collective efforts of the community, we added parallax and corrected a couple of bugs. You can also help a bit by making
fork -> fix -> pull request , if you find a bug and fix it. By the way, I remembered the words of the creator of the Retro City Rampage at Vancouver Global Game Jam 2013 about the right team member, the quote is not accurate: “A good teammate is when you tell him to draw a car with a spoiler, and he draws the perfect car with a spoiler, without any unnecessary questions about the color, size and thickness of moldings. "
2. Polishing Texts
For some reason, until recently I thought that English was a mandatory requirement in the Telegram competition for bots. However, going to the contest site now, I could not find anything like it. In any case, this affected our internal structure of the bot - at first we wanted to make it in two languages: English and Russian, but then we decided to leave only English. Most of the clients who make good money for developers speak English - that's why we chose this language.
So, unfortunately, our team did not have a native speaker. But, well, I live in an English-speaking country and it was not difficult to find a person to check the texts. However, this man also had his own affairs! Therefore, we had to wait around 3 weeks for polishing texts. And that's how it turns out: if you want to do something for free, you need to wait. By the way, I always spend a lot of time on preparing everything for people who help me for free. If a person comes to repair your motorcycle, so prepare his workplace, tools and clean your bike! The texts, by the way, have not been able to sufficiently polish everything - only superficially so far.
3. The difficulties of newbies in javascript
Oh, here we seem to have hit all the pitfalls in JavaScript that were! Most of the problems surfaced somewhere in the middle of the development cycle with the project being translated into ES6. Then there were Arrow Functions, and modules, and all-all-all new. But, do not worry! Read the
Airbnb Style Guide and it went. Of course, I had to shovel half the code, but it was worth it. If you work in a team - be sure to agree on the style of writing code before the start of the project. And then you change the spaces for tabs and vice versa.
Then began the ambitious mistakes of newcomers in trying to assemble a complex architecture, and in particular, callback hell. We decided this was not a particularly difficult way - we started using Promises everywhere, it made our code cleaner and more readable. Then we completely got rid of Express - because we no longer needed it here.
In short, when you start working on a project in a new programming language, always read the best practices guides in advance and be patient. Another great thing would be to enlist the support of a good mentor or similar projects whose code is publicly available — for reference on how to write code and what programming patterns to use.
4. Difficulties with Telegram
Do not misunderstand me, the architecture and API of our favorite messenger are wonderful, and I’m sure I couldn’t write better. But to understand how to get an answer to pressing the inline-keyboard or how to fasten a callback way to communicate with the bot, it was a bit difficult for us, beginning server programmers. Actually, these are the two points that put us in a dead end for a couple of days.
The first - when you send an inline-keyboard in one place, and you process the click completely in another - you managed to overcome it with the help of the global event emitter, I know that the pattern is bad, but it works. Second - I just had no idea how https worked until the integration into Telegram - but now I figured it out. All these keys and certificates - brr, difficult.
5. What technology stack to choose and where to host?
As a matter of fact, we immediately decided on the stack: there was just a fair amount of debate about the correctness of the choice. Someone said that Python would be easier, someone spoke for Ruby. But, we stocked up with patience, as usual, took
an open framework for communicating with the Telegram API and wrote the same. For the database, they took the usual MongoDB. Express we did not use as unnecessary, as I noted above.
The second question: where to place the server bot? Chose the option Digital Ocean (Heroku was very expensive when scaling the load). But, here's the problem: we chose a server in San Francisco and the bot's response speed, to put it mildly, did not suit us. You press the button, after half a second the bot received the request and another half second sent the request back to the Telegram server. What to do? We transferred the bot from constantly polling data from the server every half second to webbooks - when Telegram servers themselves inform our bot of new data. It helped very little. They began to think: why does everything work almost instantly for other bot-dealers? They asked Telegram game developers in different chats and found out that if you stay on Digital Ocean servers in Amsterdam, you will feel that the Telegram server is in the same rack. Checked - turned out to be true. Now our bot has become hyper-fast.
6. How to issue a rating to the user?
We sort the freelancers by ranking in the issue after the job is created by the client. But how to make a 5-star freelancer not higher than a freelancer with a hundred reviews with an average rating of 4.95? The answer turned out to be quite simple, there is even a
pretty good article about it. We translated a small script for Node.js and we no longer use the average number for ranking freelancers.
How can you help the development of the bot?
Absolutely all the code was written by volunteers, and no one is going to monetize the service in any way. So that we have the opportunity to continue to support an open freelance exchange free of charge, we need your help. You can help in several ways:
- Register on the exchange and fill out your freelance profile
- Write about us in your blog or on your resource.
- Share with friends on social networks
- And, of course, help with the code - very soon we will jump over the threshold of 1000 users and put the code in open access.
We will all be very grateful for any assistance provided to the project!
From myself I will say a special thank you to everyone who has somehow helped writing the exchange - guys, you are a fire! Without your support this project could never see the light.
Conclusion
Thank you for reading to the end!
So we wrote our first big bot for Telegram. I tried to slightly cut down the article to leave the most useful and most important thing for the average reader. I also cut out all the links to the bot, so that the Habrahabr moderators inadvertently did not send a link for the article (even from the image-caps).
I am pleased to answer any questions in the comments!