This event logs messages sent to direct messages with the bot, containing user ID, conversation data (new or existing), and conversation ID for replying. Enabling AutoFetchMessages
in the Highrise
class allows listening to these messages without additional coding. Use it to conveniently log incoming messages.
const { Highrise, Events } = require("highrise.sdk");
// Create a new instance of the Highrise class.
const bot = new Highrise({
Events: [
Events.DirectMessages // Listen for direct messages.
],
AutoFetchMessages: true, // Fetches messages on direct message events.
});
bot.on("messageCreate", (user_id, data, message) => {
console.log(`[DIRECT MESSAGE]: ${user_id}:${data.id} - ${message}`);
// This will only work if the AutoFetchMessages option is set to true.
bot.direct.send(data.id, `You said: ${message}`);
});
Go Back: Get Methods