Skip to content
Documentation
Documentation

Message Formatting

Every built-in adapter has an opinionated default message format. Override it globally or per event type.

slackAdapter({
token: process.env.SLACK_BOT_TOKEN!,
format: {
voice: (event) => ({
text: `🎤 ${event.user.name} recorded feedback on "${event.section.name}"`,
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*${event.user.name}* (${event.user.email})\n*Section:* ${event.section.name}\n*Note:* ${event.note ?? ''}`,
},
},
],
}),
'thumbs-up': (event) => ({
text: `👍 ${event.user.name} liked "${event.section.name}"`,
}),
'thumbs-down': (event) => ({
text: `👎 ${event.user.name} flagged an issue with "${event.section.name}"`,
}),
},
})

A single function receives every event:

slackAdapter({
token: process.env.SLACK_BOT_TOKEN!,
format: (event) => ({
text: `[${event.projectName}] ${event.type} from ${event.user.email} on "${event.section.name}"`,
}),
})
discordAdapter({
webhookUrl: process.env.DISCORD_WEBHOOK_URL!,
format: (event) => ({
embeds: [{
title: `${event.type}${event.section.name}`,
description: event.note,
color: event.type === 'thumbs-up' ? 0x41a148 : 0xdc2626,
fields: [
{ name: 'User', value: event.user.name, inline: true },
{ name: 'Email', value: event.user.email, inline: true },
],
timestamp: event.timestamp,
}],
}),
})
webhookAdapter({
url: process.env.WEBHOOK_URL!,
format: (event) => ({
source: 'mus',
eventType: event.type,
from: event.user.email,
page: event.section.name,
message: event.note,
ts: event.timestamp,
}),
})

All format functions receive a BaseEvent (plus event-specific fields). The fields you can use:

FieldTypeDescription
event.typestringvoice, thumbs-up, thumbs-down, support, standalone
event.projectNamestringFrom MusConfig.projectName
event.projectSlugstringURL-safe project identifier
event.user.namestringResolved from user config or auth
event.user.emailstringResolved from user config or auth
event.section.idstringFrom FeedbackTarget.sectionId
event.section.namestringFrom FeedbackTarget.sectionName
event.timestampstringISO 8601
event.notestring?User’s optional text note
event.audioBufferBuffer?MP3 (voice events only)
event.screenshotBufferBuffer?PNG (standalone events only)