MiscMessageGenerationOptions
Options that can be passed when sending messages to control various aspects like quoting, ephemeral messages, timestamps, and more.
type MiscMessageGenerationOptions = MinimalRelayOptions & {
timestamp?: Date
quoted?: WAMessage
ephemeralExpiration?: number | string
mediaUploadTimeoutMs?: number
statusJidList?: string[]
backgroundColor?: string
font?: number
broadcast?: boolean
}
Core Options
timestamp
Optional custom timestamp for the message. If not provided, current time is used.
Example:
await sock.sendMessage(jid, { text: 'Hello' }, {
timestamp: new Date('2024-01-01T12:00:00Z')
})
quoted
The message you want to quote/reply to. Pass the full WAMessage object.
Example:
// Quote/reply to a message
await sock.sendMessage(jid,
{ text: 'This is a reply' },
{ quoted: originalMessage }
)
Type Reference:
type WAMessage = proto.IWebMessageInfo & {
key: WAMessageKey
messageStubParameters?: any
category?: string
retryCount?: number
}
ephemeralExpiration
Disappearing message expiration time in seconds. Common values:
86400 - 24 hours
604800 - 7 days (default)
7776000 - 90 days
0 - Disable disappearing messages
Example:
// Send a message that disappears after 24 hours
await sock.sendMessage(jid,
{ text: 'Secret message' },
{ ephemeralExpiration: 86400 }
)
// Disable disappearing messages for this message
await sock.sendMessage(jid,
{ text: 'Permanent message' },
{ ephemeralExpiration: 0 }
)
Note: The default ephemeral expiration is defined as:
const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60 // 7 days
Timeout in milliseconds for uploading media to WhatsApp servers. Default is 30000ms (30 seconds).
Example:
// Increase timeout for large media files
await sock.sendMessage(jid, {
video: fs.readFileSync('large-video.mp4')
}, {
mediaUploadTimeoutMs: 60000 // 60 seconds
})
Status & Broadcast Options
statusJidList
Array of JIDs to send status messages to. Used when sending to status@broadcast.
Example:
// Send status to specific contacts
await sock.sendMessage('status@broadcast', {
text: 'My status update'
}, {
statusJidList: [
'[email protected]',
'[email protected]'
]
})
backgroundColor
Background color for status messages (hex color code).
Example:
await sock.sendMessage('status@broadcast', {
text: 'Colorful status'
}, {
backgroundColor: '#FF5733',
statusJidList: ['[email protected]']
})
font
Font type/style for status messages. WhatsApp supports different font styles for text statuses.
Example:
await sock.sendMessage('status@broadcast', {
text: 'Status with custom font'
}, {
font: 2,
backgroundColor: '#000000',
statusJidList: ['[email protected]']
})
broadcast
Whether this message is a broadcast message.
Example:
await sock.sendMessage('[email protected]', {
text: 'Broadcast message'
}, {
broadcast: true
})
Relay Options
messageId
Override the auto-generated message ID with a custom ID.
Example:
await sock.sendMessage(jid,
{ text: 'Custom ID message' },
{ messageId: 'MY_CUSTOM_MESSAGE_ID_12345' }
)
Whether to use cached group metadata or fetch fresh from the server.
Example:
// Force fresh group metadata fetch
await sock.sendMessage(groupJid,
{ text: 'Group message' },
{ useCachedGroupMetadata: false }
)
MinimalRelayOptions
Base options inherited by MiscMessageGenerationOptions.
type MinimalRelayOptions = {
messageId?: string
useCachedGroupMetadata?: boolean
}
MessageRelayOptions
Extended relay options used internally for message relay operations.
type MessageRelayOptions = MinimalRelayOptions & {
participant?: { jid: string; count: number }
additionalAttributes?: { [_: string]: string }
additionalNodes?: BinaryNode[]
useUserDevicesCache?: boolean
statusJidList?: string[]
}
participant
participant
{ jid: string; count: number }
Send only to a specific participant. Used when message decryption fails for a single user.
JID of the specific participant
Retry count for this participant
additionalAttributes
additionalAttributes
{ [key: string]: string }
Additional attributes to add to the WA binary node.
additionalNodes
Additional binary nodes to include in the message.
useUserDevicesCache
Whether to use the devices cache or fetch fresh from the server.
Usage Example
Complete example showing multiple options:
import makeWASocket from '@whiskeysockets/baileys'
const sock = makeWASocket({ /* auth config */ })
// Send a quoted message with ephemeral expiration
const sentMsg = await sock.sendMessage(
'[email protected]',
{
text: 'This is a reply that will disappear',
mentions: ['[email protected]']
},
{
// Quote the original message
quoted: originalMessage,
// Make it disappear after 24 hours
ephemeralExpiration: 86400,
// Custom timestamp
timestamp: new Date(),
// Custom message ID
messageId: 'custom_id_123',
// Force fresh group metadata
useCachedGroupMetadata: false
}
)
console.log('Message sent:', sentMsg.key.id)
Status Message Example
// Send a styled status update to specific contacts
await sock.sendMessage(
'status@broadcast',
{
text: '🎉 Check out my new status!'
},
{
backgroundColor: '#4A90E2',
font: 3,
statusJidList: [
'[email protected]',
'[email protected]',
'[email protected]'
]
}
)
import fs from 'fs'
// Send large video with extended timeout
await sock.sendMessage(
jid,
{
video: fs.readFileSync('large-video.mp4'),
caption: 'Check out this video!'
},
{
// Extend timeout for large file
mediaUploadTimeoutMs: 120000, // 2 minutes
// Quote another message
quoted: previousMessage
}
)