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

Parameter

Type

Description

options

Object

Optional

An object containing the property conversationId

function(callbackResponse, error)

Function

Optional

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.

Property

Type

Description

conversationId

String

Required

The conversation that you fetched message history for.

messages

Array

Required

A list of messages found on that conversation.

See messages 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 for an example of what this looks like.

pages

deprecated

Object

Optional

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

Did this page help you?