Tutorial: Welcome Bot
📄️ 1. Overview
In this tutorial, you'll build a Bot that counts the number of messages each user posts and assigns a special role after they post their 5th message. This is a much-simplified version of a common community-management Bot that could welcome new members, monitor their activity, give them more access as they participate, and so on.
📄️ 2. Setup
You can develop for the Root Platform on Windows or macOS. You'll need to do a few Root setup tasks before starting to write code. Skip any steps that you've completed previously.
📄️ 3. Generate starter code
Root supplies a command-line utility named create-root that generates starter code. Here, you'll create your project, build it, and test that it works with your community.
📄️ 4. Create the role
Recall that this Bot is a simplified version of typical community management software. The key task we're automating here is the new-member transition from probationary to participant.
📄️ 5. Store message count
You need to store the number of messages each member posts. To make sure your code works even if your Bot restarts, you should use the Root API's KeyValueStore type. Root automatically backs up and restores the key-value store, so your data is persistent.
📄️ 6. Assign the role
The Participant role appears inside the community as a text string. Behind the scenes, Root assigns each role a unique ID number of type CommunityRoleGuid. You'll need the role ID to assign the role to a member.