KustomerCore.getHistoricalMessages()

Fetches the historical message history for a conversation

👍

First, initialize chat

You must initialize with KustomerCore.init() before you can execute any additional Core SDK methods

Examples

// Get messages with a conversationId 
KustomerCore.getHistoricalMessages({
  conversationId: 'SOME_ID',
  count: '25',
  before: '2022-04-07T23:20:29.080Z'
}, function (callbackResponse, error) {
  console.log('Fetched messages!', messages);
});

Syntax

KustomerCore.getHistoricalMessages(options, function(callbackResponse, error))
ParameterTypeDescription
optionsObjectOptional

An object containing details about the messages you want to fetch. A breakdown of the options object is listed below.
function(callbackResponse, error)FunctionOptional

A callback that is run after KustomerCore.getHistoricalMessages() completes.

callbackResponse is an object returned to the callback function. See the callbackResponse section below to see the properties of the object.

error is either undefined or a native JavaScript Error object.

options

PropertyTypeDescription
conversationIdStringRequired

The unique ID of the conversation that you are fetching message history for.
countNumberOptional

The number of messages you want to fetch.

The default value is 25.
beforeDate-timeOptional

Fetch messages before a given date. This is a ISO formatted string, for example, YYYY-MM-DDTHH:MM:SS.SSSZ

callbackResponse

PropertyTypeDescription
messagesArrayRequired

A list of messages found on that conversation.

See messages below for an example of what this looks like.
satisfactionObjectOptional

An object with details about the satisfaction form message in this conversation.

See satisfaction below for an example of what this looks like.

messages

// messages

[
  {
    messageId: String,
    body: String,
    createdAt: String,
    direction: String,
    conversationId: String,
    attachments: Array,
    meta: {
      template: Object,
      articles: Array
    },
    sentBy: {
      type: String
      id: String,
      displayName: String,
      avatarUrl: String
    },
  }
]

satisfaction

// satisfaction

{
  conversationId: String,
  satisfactionId: String,
  timetoken: String,
  form: {
    description: String,
    introduction: String,
    name: String,
    followupQuestion: String,
    ratingPrompt: String,
    scale: {
      options: String,
      labelLow: String,
      labelHigh: String,
      type: String,
    },
  },
  response: {
    rating: Number,
    followupAnswer: String,
  },
}