Skip to content

Mailbox

Letters a player reads in the game: a gift you sent, a notice that a payment went through, an apology for the maintenance of last night. Your game server or an operator writes one to one player; the game shows the list and the unread count.

const mails = await rudder.mailbox.list();
const unread = mails.filter((mail) => !mail.read).length;

From your game server, with the server key of the environment:

await rudder.mailbox.send({
title: "Welcome",
body: "Your starter sword is waiting in the inventory.",
icon: "sword",
});

The letter goes to the player named in the call, so one send reaches one player.

From the Dashboard, open the player on Players and use Send on the Mail card: the same form, with the same limits, without code.

A letter is unread until the client marks it read, and it stays after that until the player removes it or the mailbox makes room for a newer one. list answers every letter of the player, newest first; there is no count of its own, so a client counts the unread ones itself.

FunctionKindCallerArgumentsResult
sendmutationgame server{title, body, icon?}the letter, with its id
listqueryclientnone{id, title, body, icon?, createdAt, read}[], newest first
readmutationclient{id?}none: marks one letter read, or every letter when id is empty
deletemutationclient{id}none

icon names an icon of the game, in the same way the other modules name theirs; a client that does not know it shows the letter without one.

  • A title is at most 120 characters, a body 1000 and an icon 64; a longer letter is refused with mail_too_long, and a letter of an id the player does not have answers unknown_mail.
  • A player keeps the 100 newest letters. A sender never finds a full mailbox: the oldest read letter makes room for the new one, and the oldest unread one when every letter is unread.
  • No attachments: a letter carries no item and no currency, so there is nothing to claim and nothing that can be lost. Grant rewards with the inventory or a store, and send the letter as the notice.
  • One language: a letter is written in the language of the call, and the Dashboard shows it as it was sent. Localized texts are a later step.
  • No templates and no letters written by other modules: this version writes what a game server or an operator sends. A letter from an event of another module, such as an outbid, is a later step.