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))

Parameter

Type

Description

options

Object

Optional

An object containing details about the messages you want to fetch. A breakdown of the options object is listed below.

function(callbackResponse, error)

Function

Optional

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

Property

Type

Description

conversationId

String

Required

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

count

Number

Optional

The number of messages you want to fetch.

The default value is 25.

before

Date-time

Optional

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

callbackResponse

Property

Type

Description

messages

Array

Required

A list of messages found on that conversation.

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

satisfaction

Object

Optional

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

Did this page help you?