KustomerCore.getMessages()

Fetches the 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.getMessages({
  conversationId: 'SOME_ID'
}, function (messages, error) {
  console.log('Fetched messages!', messages);
});

Syntax

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

An object containing the property conversationId
function(callbackResponse, error)FunctionOptional

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

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

error is either undefined or a native JavaScript Error object.

callbackResponse

This will return all responses from the last 30 days.

PropertyTypeDescription
conversationIdStringRequired

The conversation that you fetched message history for.
messagesArrayRequired

A list of messages found on that conversation.

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

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

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

deprecated
ObjectOptional

This is an object giving details about the page you are on, that looks like this:

{ current: Number, first: Number, next: Number, previous: Number }

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,
  },
}