Messages Retrieval:

The method inbox.messages.get() is used to retrieve messages from a specific conversation. It requires two parameters:

  1. conversationId (string): The ID of the conversation from which messages are to be retrieved. If not defined, it will return a server error. The bot must be in the conversation for this method to work.
  2. lastMessageId (string): Optional. Specifies the ID of the last message to start fetching from. If omitted or set to null, the method returns the last 10 messages from the conversation.
// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", async (user, message) => {
	const convo = "1_on_1:649d9759cfb5ce5a4ef0d3a6:64b2d35c8893a95b02d668cf";
	const lastId = "65e102aab38258ac50bce726"
  if (message === "messages") {
    bot.inbox.messages.get(convo, lastId).then((messages) => {
      console.log(messages);
    }).catch(e => console.error(e));
  }
});

Example Output:

[
  {
    "message_id": "65e102a9a438f687dbdf615a",
    "conversation_id": "1_on_1:649d9759cfb5ce5a4ef0d3a6:64b2d35c8893a95b02d668cf",
    "createdAt": "2024-02-29T22:18:17",
    "content": "hello",
    "sender_id": "649d9759cfb5ce5a4ef0d3a6",
    "category": "text"
  }
]

Go Back: Bot Inbox