KodaBot, pt. 1
Tags: serverless, autocode, cloudflare, kodadot
Published: 2022-05-31 10:00:00

**Coordination problems** are a well-known subject within the web3 ecosystem. As a remote-first, open-source, and public good company, KodaDot has run into coordination issues related to async workflow. In this article, I will cover the process of designing and deploying our first version of KodaBot -> multi-purpose bot designed to help with the coordination of contributors to KodaDot repositories.


### The Problem

*Double-spending is a potential flaw in a digital cash scheme in which the same single digital token can be spent more than once. Unlike physical cash, a digital token consists of a digital file that can be duplicated or falsified* - Investopedia.com

While the analogy isn't perfect, **double-spend** is a helpful term to describe a process we saw repeating in [KodaDot's GitHub repository](https://github.com/kodadot/nft-gallery). The developer picks an issue she'd like to work on, she posts a comment declaring her intent, and the very next day, PR for the said issue is being opened by another dev. Effectively, two devs were spending their time working on the same problem, and only one solution was accepted. This results in the pointless burning of precious dev's neurons, frustration, and the sense that there is no security in working on long-term issues within the project. "First come, first serve" works in many places, but it kept backfiring in our rich dev's community.

And since we want to keep the devs happy...

### The Solution

*Assign bot: Autocode + Cloudflare's key-value storage*

After numerous iterations, we've decided to solve this problem with a combination of **Autocode and Cloudflare's key-value storage**. We've set up webhooks in our repositories, which are being sent directly to serverless Autocode's endpoint. To preserve the states of the assignment and developer's profile, we are using Cloudflare's KV storage. The bot is checking the state of assignments every minute.

  
**Assigning Issues**

Each developer has a **limit of 5 issues** being assigned to him at any time. Getting unassigned, dropping out of the queue, or passing on the option to pick the issue forbids dev from further participation in said issue. We've made this decision because we want to incentivize thinking carefully about which issue to pick to avoid stalling and slowing others down. Since we have plenty of **outside contributors** (70+) to our repository, we needed to create a process in which newcomers can get issues assigned with a guarantee that they'd be able to work on the issues for a given period, based on the bounties provided in labels. When a developer finds an issue she'd like to work on, using `:wave:` emoji ->['👋', '👋🏻', '👋🏼', '👋🏽', '👋🏾', '👋🏿'] will trigger the bot to assign her the issue. Time allocated for each assignment is calculated based on bounty label, while long term (10+ merged PRs) contributors gain 50% time boost for each issue. Issues without a bounty label get a **default 24 hours limit**:

    - $: 24h
    - $$: 48h
    - $$$: 72h
    - $$$$: 96h
    - $$$$$: 120h



![KodaBot assigns developer with issue.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/he6co21rx3edh8q2aw1x.jpg)

**Getting into the queue**

If the developer finds an issue she'd like to work on, but the problem is already assigned to another dev, she can get into the queue behind the assignee. Once the locked period expires, the next dev in a queue will be given an option of 12 hours to react to the issue (either get it assigned or drop out of the queue). Dropping out of the queue or passing on the option by commenting `pass` on said issue.


**Securing the issue with PR**

Once the issue is done or close to being done, opening a PR with the progress made by the developer will ensure that the bot won't unassign the developer even after the time runs out. 


![KodaBot verifies that developer opened up PR for issue assigned to him.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sr4y01iybwgj014bit1i.jpg)

**Ignoring specific issues**

Collaborators in the repository (currently seven developers and three non-tech contributors) are given the right to make the bot ignore a particular issue. Devs can do this by commenting with `ignore` on said issue. We created this function to speed up the process with specific issues that don't require the bot's supervision, such as minor fixes or issues particular to some team members.


## Conclusion

Leveraging Autocode and Cloudflare's KV storage provided us with the solution to the coordination problem within the remote+async first dev culture. As we've polished up and finished developing v1 of the bot, there are already numerous ideas about v2, including introducing Quadratic Funding and other automatizing payout processes within the KodaDot. 

### [Come and try out  KodaBot 💻🤖 yourself!](https://github.com/kodadot/nft-gallery/issues) 



### We are always hiring:

-   [Frontend Engineer — VueJS/Typescript](https://kodadot.xyz/jobs)
-   [Technical Product Manager](https://kodadot.xyz/jobs)
-   [Senior Business and Operations Manager](https://kodadot.xyz/jobs)
-   [Rust developer](https://kodadot.xyz/jobs)


### Reach out to KodaDot:

-   [Discord](https://discord.gg/35hzy2dXXh)
-   [Twitter](https://twitter.com/kodadot)
-   [Yangwao](https://twitter.com/yangwao)
-   [Vikiival](https://twitter.com/vikiival)

### MetaPrime

-   [Twitter](https://twitter.com/metaprime_net)
-   [Medium](https://medium.com/metaprime)