fetchPanelAgentChatHistory(params: FetchPanelAgentChatHistoryParams)

Requires:
@tuya-miniapp/cloud-api≥1.0.6

Description

Query historical session records (supports cursor pagination).

Parameters

ParameterTypeRequiredDescription
YesRequest body

Return Value

Type: Promise<FetchPanelAgentChatHistoryResult>
FetchPanelAgentChatHistoryResult (See type definitions and minituya return parameters for field meanings)

Referenced Types

typeFetchPanelAgentChatHistoryResult
FetchPanelAgentChatHistoryItem[]

Valid Values

FetchPanelAgentChatHistoryParams.bindRoleType
ValueDescriptionSince
0--
1--
2--

Examples

Request example

import { fetchPanelAgentChatHistory } from '@tuya-miniapp/cloud-api';

const params = {
  devId: 'your_device_id',
  bindRoleType: 0,
  roleId: 'role_12345',
  gmtStart: 1699200000000,
  gmtEnd: 1699286400000,
  fetchSize: 20,
  timeAsc: false,
};

fetchPanelAgentChatHistory(params)
  .then(result => {
    console.log('Chat history:', result);
  })
  .catch(error => {
    console.error('Failed to get chat history:', error);
  });

Response example

[
  {
    "docId": "doc_001",
    "createTime": "2023-11-06 10:30:00",
    "requestId": "req_12345",
    "question": [
      {
        "id": "q_001",
        "context": "How is the weather today?",
        "type": "text"
      }
    ],
    "answer": [
      {
        "id": "a_001",
        "context": "It's sunny today, with a temperature of 22°C.",
        "type": "text"
      }
    ],
    "gmtCreate": 1699200000000
  }
]