Message events receive MessageContext. Conversation events receive ConversationContext. start and stop receive ClientContext. unhandledError receives an Error. Error middleware receives a partial context with a client and optional message and conversation.
Property or method
Purpose
client
Node SDK client
conversation
Current conversation
message
SDK message with tagged content, for message events
content
Decoded value, for message events
getClientAddress()
Current client’s account identifier
isDm(), isGroup()
Narrow the conversation type
isAllowed(), isDenied(), isUnknown()
Read conversation consent state with await
sendRemoteAttachment(file, callback?)
Use backend attachment hosting, or an app upload callback
Adds the listener function to the end of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName
and listener will result in the listener being added, and called, multiple
times.
server.on('connection', (stream) => {
console.log('someone connected!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The
emitter.prependListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Start conversation and message streams. Calling this while running is a no-op.
start();
The context exposes the underlying conversation. Use its SDK methods for members, messages, metadata, and content-type send helpers.
For a text event, read the string from ctx.content. ctx.message.content is a tagged record, such as { kind: "text", value: "hello" }. For a reply, ctx.content is the reply record with referenceId and body. Read-receipt contexts have undefined content.
Assigning ctx.content changes the value used by later middleware. It does not change ctx.message. The command router uses this property to pass command arguments to its handler.
sendReaction(), sendTextReply(), and sendMarkdownReply() disable push notifications. Use the underlying conversation send methods when you need other send options.