How we wrote a freelance exchange for Telegram



    Good afternoon, dear Khabravchians! Today I decided to tell you about our experience in creating a bot for Telegram on Node.js with almost no experience in server development and on a voluntary basis. I’ll make a reservation right away: I’ve got a little more than four years of iOS development behind me, the rest of the team also had one to six years of development experience in related fields. For most of us, this was the first use of Node.js 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 fought with them - under the cut!

    How did it all start?


    It just 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 transfer code from one contractor to another, and the like. Having gained enough experience, he began to share it on social networks, from which a small (273 people at the time of writing the topic) group grew up in Telegram; where we flood, communicate, help each other and watch online development streams.

    About six months ago, I began to study Node.js for self-development and, more recently, I wrote a couple of game bots exclusively for our channel. Then the guys pulled themselves up - wrote a couple more bots (by the way, we put all bots in the public domain - carefully, I’m not vouching for the integrity of your ok) There are slots, and Russian roulette, and their own currency "Helionics" is (named after one of the oldfags of our party).

    By the nature of my profession, I have a contact list of trusted programmers (iOS, Android, Web) that I have already worked with and which I collect from time to time in teams to launch or support startups of clients who receive funding. Initially, my contact list was on Skype, but today I have completely migrated to Telegram. And now, once again sending out job offers to talented programmers, I caught myself thinking: why can't this process be automated? I do it every 2-3 weeks. Here the idea came up to create a bot that does this for us. You throw him a job description, and he immediately gives out a list of freelasers in the right category and with the right hourly rate.

    Having slept with the idea, having talked with a couple of clients, having discussed the idea with friends from the warm and lamp Telegram chat, it was decided to make an exchange over the weekend, having assembled a small team and brewing a couple of tea pots. But it wasn’t there - two days turned into four weeks!

    Initially, our goal was to make a convenient free freelance exchange and then post the code in the public domain. We decided to never monetize the service and support it with our own money from breakfast. But the 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 application text:

    Push me!
    #BotPrize

    Good morning dear Telegram Bot Support team! We've recently heard about Telegram bot contest and started to build the freelance market within Telegram. Our bot's handle is @ * bot * - this submission may seem too preliminary but we decided to message you sooner rather than later. Let me give you some details about who we are, what is @ * bot * and what are our plans!

    First of all, we have built this bot together with my friends-developers from @borodutcher (we've built the whole chat currency platform privately for our group with multiple game bots using it - but that's a completely different story). Right now we have 5 active members of our team and we have been building this bot for the last 4 weeks. I have live streamed development on livecoding.tv/backmeupplz - some of the saved videos just hit over 5000 views, so we try our best to make Telegram more and more popular :)

    Our current situation is almost production ready: we have used web-hooks to make bot work as fast as possible and used Node.js with MongoDB to manage bot's logic. We have a couple of tasks left like fixing minor pretty hard to catch bugs and going through bot texts with native English speaker - but that's all minor things.

    So what is @ * bot *? It's a completely Telegram-native freelance market with revolutionary system, here are some things by which it is different from classic freelance market system:

    1. With classic freelance system, after a client publishes a job, it is visible to everybody and everybody can respond to it - that leads to a lot of unnecessary spam-like freelancer's offers. In our case, client chooses who should receive job offer by looking at freelancers' bios.
    2. With classic freelance system, after a client posts his job, he needs to wait for some time before getting first responses. In our case, straight after client has published his job, we send him a list of 10 freelancers with the best rating and the ones who are best suitable for this job. After that, client is free to choose freelancers who should receive job offer. No need to wait!
    3. With classic freelance system, it is pretty hard for first time clients to pick the right price for the job - it's almost like a block box for them. In our case, our statistics is opened and after client has selected category he sees how many freelancers are available in each price category - this gives clients insight about how much should the job cost.
    4. With classic freelance system, markets tend to either prohibit client-freelancer communication till the point when deal is sealed. In our case, because of awesome Telegram abilities, clients may message freelancers as soon as they appear on the list and freelancers can message clients as soon as clients decide to send them job offer.
    5. With classic freelance system, freelancers have to be hyper-proactive monitoring markets and answering every single suitable job posting. In our case, as soon as freelancer fills in his profile (bi, categories, hourly rate), the only thing he needs to do is to lay back and keep up good job (to gain rating) - he will receive job offers if any clients would like to work with him.
    6. And, the most important thing. Most of the classic freelance services are commercial-oriented: they have membership fees, transaction fees, connection fees, feature fees, etc. In our case, we decided to keep bot completely non-profit. Which means that we claim to drive this system only on matters of providing users with stable and friendly service.
    7. The last but not the least, most of classic freelance market never open source their code - because of very high risk to become vulnerable to hacker and competitor attacks. In our case, we decided to make this freelance market completely open-sourced so that everybody could fork it, fix a bug or add a feature and make pull request. This will be a completely open and community-oriented system. We plan to open source full codebase as soon as we reach the threshold of 1000 registered users. To better support our claims, we open-source our bots on almost monthly basis: github.com/borodutch.

    And did I mention that this freelance marked is 100% based on Telegram? We have no other places to publish or respond to a job but Telegram. No need to login anywhere - just start the bot and you are all set!

    What are our plans for future?

    1. First, we will fix some minor bugs and work on more user-friendly texts.
    2. We will launch a website with user number statistics and all differences from classic freelance market system. We plan to host on github pages this time and make website code to be fully open source as well.
    3. We plan on writing about our bot on habrahabr.ru (by the way, I still hold badges of the best author in Obejctive C and iOS Development hubs - habrahabr.ru/users/backmeupplz/) producthunt (I recently got an invite there as well - producthunt.com/@nikitakolmogorov), reddit, pikabu and vc.ru with details about development process, difficulties we faced, etc. We hope this will bring attention to our bot and we will get 1000 users in relatively short period in time.
    4. After we gain critical user-base we plan on implementing new features requested by users and improve existing ones.

    This is it - our freelance chat bot market in the nutshell. We have used inline keyboards as well as usual keyboards to enhance UX; we even have pagination in one of the inline keyboards;)

    Why would we like to join the Bot contest? Well, this bot was created as a side project and we kind of didn't spend nothing but our time on it - which means that there were almost no development costs. If we would be considered as suitable contestants and (luckily) get grant, it would definitely help us to start working full time on this bot platform and put all our efforts towards gaining more and more users while satisfying majority of them with service (ideally, all of them). It would also be a great help for us to keep this bot open-source and completely free for users - but that kind of our philosophy, we really want this to happen. In a sense, grant would help us grow our user-base and support further development.

    On the last note I would like to thank you for building such a great chat bot platform! Again, we don't have many users right now but we still decided to message you sooner than later :) In case you like it;)

    Thank you a lot for reading such a huge intro to 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? About two years ago, I would ask the same question, but recently I switched to the other side of freelance exchanges: from freelancer to clients. And if you didn’t like the way exchanges work on the part of the freelancer, believe me, on the client side the picture looks even worse.

    Suppose you need to create a website and you are looking for a good contractor - post an ad on the same Upwork, what's next? The hell begins, on which you spend the lion's share of your time: a ton of terrible spam mails comes from obscure studios from India. Okay, weed them out. What to do with the second ton of applications? Oh, there are too many of them - we filter out everyone with a rating below 4.8 stars. Oh, there are still 130 applications left. Okay, we filter out the portfolio - what you like or dislike. Oh, again around 40 applications remained. Well, it’s okay, I’ll write to everyone a carbon copy of the answers and ask for contact details for communication. Oh, how long is it all. And then also to communicate with everyone - it’s also not clear how much this all costs, we should ask everyone.

    Is it possible to automate this process? After conferring, we thought out an alternative system of freelance exchange with several differences from the classical model:

    1. The client receives a list of the top 10 freelancers as soon as he creates a new job. From this list, the client chooses to whom to send a job offer.
    2. The freelancer only needs to fill out his profile and follow the rating - the offers will come to the freelancer themselves if the customers like the profile.
    3. The exchange is absolutely free and will remain so forever. We do not block communication between the client and the freelancer and do not use tricky methods of withdrawing money.
    4. As soon as we have 1000 active users, we will post the bot code in open access, so that everyone can fix the bug or add a function if he wants.

    By introducing this series of changes and giving the exchange control to the community, we hope to improve the quality of communication between customers and customers, speed up the process of finding a contractor and concluding a deal. No sooner said than done: the bot works fine with 176 users at the time of writing.

    How did we organize the work?


    As a result, we had five programmers without obvious management - you yourself know what this all leads to. Out of habit, we started using Trello - it's free and fairly simple - to track bugs and tasks. They threw a simple structure with columns such as “To do”, “Working”, “Testing”, “Done”, “Future” and threw cards between them. So this disgrace looked:



    We could use both JIRA and the BitBucket bug tracker, but all this seemed to us too large and cumbersome for our relatively small project. Moreover, at BitBucket we don’t really want to linger. As soon as we hit the mark of 1000 users, we will transfer the code to open access on GitHub. In our team, anyone could create a new card with a bug or features, and after conferring, we either attached the card to one of us, or transferred the card to the “Future” column - ideas left for the future. We really wanted to launch MVP - we had to cut our Wishlist to the maximum.

    We often conferred precisely in Telegram. Considering that we had different experience in developing JavaScript and Node.js, we learned from each other's mistakes and tips. If someone threw a bad commit into their branch, then we quickly corrected it. By the way, at the beginning we used nicknames on BitBucket as the name of the branches, but then switched to the Orthodox names of features - it became much more convenient for us to commit to each other's branches.

    What difficulties did we encounter on the way?


    Of course, it’s impossible to cover all the pitfalls, but I’ll try to talk about a few particularly outstanding problems that pretty much hampered the development of the bot.

    1. Creating a website


    Rather, this problem arose because we all worked for free and none of us had any motivation except launching the product. So, the first developer to start landing for the bot turned out to be very busy with the main project, which paid his bills. Nothing terrible happened, we transferred the development to another person. Second, it happened - we don’t know, because of insufficient experience in the front-end development, this happened or because of something else, but also did not cope with the task, the result did not suit us. But now our hero appears out of nowhere and makes up the page, which was designed by one of the magnificent five tube chat programmers! And, everything is great: we host on Github Pages, bugs are corrected upon arrival, by golly, happiness! And our site has earned. Having screwed up a small statistics server,



    And then, through the collective efforts of the community, we added parallax and fixed a couple of bugs. You can also help a little by doing fork -> fix -> pull request if you find a bug and fix it. By the way, I recalled the words of the creator of Retro City Rampage at the 2013 Vancouver Global Game Jam about the right member of the team, the quote is not accurate: “A good teammate is when you tell him to draw a car with a spoiler, and he draws a perfect car with a spoiler, without any unnecessary questions about the color, size and thickness of the moldings. "

    2. Text polishing


    For some reason, until recently, I thought that English was a mandatory requirement in the Telegram contest for bots. However, having visited the contest website now, I could not find anything like it. In any case, this influenced 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 customers who bring good money to developers speak English - that's why we opted for this language.

    So, unfortunately, our team did not have a native speaker. But, fortunately, 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 so it turns out: if you want to do something for free, you need to wait. By the way, I always spend quite a lot of time preparing everything for people who help me for free. If a person comes to repair your motorcycle, so prepare him a workplace, tools and clean your bike! The texts, by the way, could not sufficiently polish everything - only superficially so far.

    3. Newbie JavaScript Difficulties


    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 switched to ES6 standard. Here came Arrow Functions, and modules, and all-all-all new. But no big deal! We 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 are tormented to change spaces to tabs and vice versa.

    Then the ambitious mistakes of beginners in trying to assemble a complex architecture, in particular, callback hell, began. We decided this in a not-so-difficult way - we started using Promises everywhere, this 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 work on a project in a new programming language, always read guides like best practices in advance and be patient. It would also be great to enlist the support of a good mentor or similar projects whose code is publicly available - for help on how best to write code and which programming patterns to use.

    4. Difficulties with Telegram


    Do not get me wrong, the architecture and API of our favorite messenger are wonderful, and I am sure I could not write better. But to figure out how to get an answer to pressing the inline-keyboard or how to fasten the callback way of communicating with the bot was a little difficult for us, new server programmers. Actually, these are two points that have put us at a standstill for a couple of days.

    The first - when you send an inline-keyboard in one place, and you process the click in a completely different one - I managed to overcome it using the global event emitter - I know, a bad pattern, but it works. The second - I just had no idea how https worked until the integration into Telegram - but now I figured it out. All of these keys and certificates are brr, complicated.

    5. What technology stack to choose and where to host?


    As a matter of fact, we decided on the stack right away: there was simply enough debate about the right choice. Someone said that it would be easier in Python, 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. We did not use Express as unnecessary, as I noted above.

    The second question: where to place the bot server? We chose the Digital Ocean option (Heroku turned out to be 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 a request and for another half a second threw the request back to the Telegram server. What to do? The bot was transferred from constant polling of data from the server every half second to webhooks - when Telegram servers themselves inform our bot about new data. It helped very little. They began to think: why did everything work for other botnets almost instantly? They asked developers of games for Telegram in various chats and found out that if you host on the Digital Ocean servers in Amsterdam, you will feel that the Telegram server is in the same rack. Checked - it turned out to be true.

    6. How to give a rating to a user?


    We sort freelancers by rating in the issuance after the creation of the work by the client. But how to make sure that a freelancer with one review of 5 stars is 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 on Node.js and we no longer use the usual average 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 maintain an open freelance exchange for free, we need your help. There are several ways to help:

    1. Register on the exchange and fill out your freelancer profile
    2. Write about us in your blog or on your resource
    3. Share with friends on social networks
    4. And, of course, help with the code - very soon we will jump over the threshold of 1000 users and put the code in the public domain.

    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 already helped in any way writing the exchange - guys, you are a fire! Without your support, this project would never be able to 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 the article to leave the most useful and most important for the average reader. I also cut out all the links to the bot, so that the Habrahabr moderators would not inadvertently be sent to the link for the article (even from the header image).

    I will be happy to answer any questions in the comments!

    Also popular now: