1# Draupnir (Matrix Moderation Bot) {#module-services-draupnir}
2
3This chapter will show you how to set up your own, self-hosted
4[Draupnir](https://github.com/the-draupnir-project/Draupnir) instance.
5
6As an all-in-one moderation tool, it can protect your server from
7malicious invites, spam messages, and whatever else you don't want.
8In addition to server-level protection, Draupnir is great for communities
9wanting to protect their rooms without having to use their personal
10accounts for moderation.
11
12The bot by default includes support for bans, redactions, anti-spam,
13server ACLs, room directory changes, room alias transfers, account
14deactivation, room shutdown, and more. (This depends on homeserver configuration and implementation.)
15
16See the [README](https://github.com/the-draupnir-project/draupnir#readme)
17page and the [Moderator's guide](https://the-draupnir-project.github.io/draupnir-documentation/moderator/setting-up-and-configuring)
18for additional instructions on how to setup and use Draupnir.
19
20For [additional settings](#opt-services.draupnir.settings)
21see [the default configuration](https://github.com/the-draupnir-project/Draupnir/blob/main/config/default.yaml).
22
23## Draupnir Setup {#module-services-draupnir-setup}
24
25First create a new unencrypted, private room which will be used as the management room for Draupnir.
26This is the room in which moderators will interact with Draupnir and where it will log possible errors and debugging information.
27You'll need to set this room ID or alias in [services.draupnir.settings.managementRoom](#opt-services.draupnir.settings.managementRoom).
28
29Next, create a new user for Draupnir on your homeserver, if one does not already exist.
30
31The Draupnir Matrix user expects to be free of any rate limiting.
32See [Synapse #6286](https://github.com/matrix-org/synapse/issues/6286)
33for an example on how to achieve this.
34
35If you want Draupnir to be able to deactivate users, move room aliases, shut down rooms, etc.
36you'll need to make the Draupnir user a Matrix server admin.
37
38Now invite the Draupnir user to the management room.
39Draupnir will automatically try to join this room on startup.
40
41```nix
42{
43 services.draupnir = {
44 enable = true;
45
46 settings = {
47 homeserverUrl = "https://matrix.org";
48 managementRoom = "!yyy:example.org";
49 };
50
51 secrets = {
52 accessToken = "/path/to/secret/containing/access-token";
53 };
54 };
55}
56```
57
58### Element Matrix Services (EMS) {#module-services-draupnir-setup-ems}
59
60If you are using a managed ["Element Matrix Services (EMS)"](https://ems.element.io/)
61server, you will need to consent to the terms and conditions. Upon startup, an error
62log entry with a URL to the consent page will be generated.