Get Conversation List And Records
Last updated:2023-11-15

Get Conversation List And Records

Get Conversation List

Get the list of all conversation IDs within a specified time range.

Request Method

GET

Request URL

https://api.gptbots.ai/v1/bot/conversation/page

Request Authentication

Please refer to the API Overview for authentication methods.

Request

Request Example

curl --location 'https://www.gptbots.ai/v1/bot/conversation/page?page=1&conversation_type=API&start_time=1691942400000&end_time=1699868066999&page_size=444' \ --header 'Authorization: Bearer your_apikey' \ --header 'Content-Type: application/json'
          curl --location 'https://www.gptbots.ai/v1/bot/conversation/page?page=1&conversation_type=API&start_time=1691942400000&end_time=1699868066999&page_size=444' \
    --header 'Authorization: Bearer your_apikey' \
    --header 'Content-Type: application/json'

        
This code block in the floating window

Request Headers

Field Type Description
Authorization Bearer ${token} Use Authorization: Bearer ${token} for authentication. Get the key from the API Keys page as token.
Content-Type application/json Data type, set to application/json.

Request Body

Field Type Required Description
conversation_type string Yes Conversation type.
  • ALL: All
  • SPACE: Workspace
  • API: BOTAPI call
  • EMBED: iframe/bubble widget
  • SHARE: Share
  • WHATSAPP_META:WhatsApp by Meta
  • WHATSAPP_ENGAGELAB:WhatsApp by EngageLab
  • DINGTALK: Dingtalk Robot
  • Discord: DISCORD
  • Slack: SLACK
  • Zapier: ZAPIER
  • start_time long Yes Start time of the recent conversation, in timestamp format.
    end_time long Yes End time of the recent conversation, in timestamp format.
    page int Yes Page number, indicating which page to request, starting from 1.
    page_size int Yes Number of data entries per page, range 1-100.

    Response

    Response Example

    { "list": [ { "conversation_id": "AaACmo05Yrqb6bOSTbsg", "user_id": "3", "recent_chat_time": 1694572952383, "subject": "2+3=?", "conversation_type": "API", "message_count": 2, "cost_credit": 0.01, "bot_id": "64b902a84f1ff25d1c60c10b" }, { "conversation_id": "64ec1508c9c1ed5605e6ff28", "user_id": "33", "recent_chat_time": 1693194862160, "subject": "Hello!", "conversation_type": "API", "message_count": 20, "cost_credit": 0.59, "bot_id": "64b902a84f1ff25d1c60c10b" } ], "total": 2 }
              {
      "list": [
        {
          "conversation_id": "AaACmo05Yrqb6bOSTbsg",
          "user_id": "3",
          "recent_chat_time": 1694572952383,
          "subject": "2+3=?",
          "conversation_type": "API",
          "message_count": 2,
          "cost_credit": 0.01,
          "bot_id": "64b902a84f1ff25d1c60c10b"
        },
        {
          "conversation_id": "64ec1508c9c1ed5605e6ff28",
          "user_id": "33",
          "recent_chat_time": 1693194862160,
          "subject": "Hello!",
          "conversation_type": "API",
          "message_count": 20,
          "cost_credit": 0.59,
          "bot_id": "64b902a84f1ff25d1c60c10b"
        }
      ],
      "total": 2
    }
    
            
    This code block in the floating window

    Successful Response

    Field Type Description
    list JSON Array List of conversations.
    conversation_id string Conversation ID.
    user_id string User ID.
    recent_chat_time long Recent conversation time.
    subject string Conversation subject.
    conversation_type string Conversation type.
    message_count int Total number of messages in the conversation.
    cost_credit float Number of credits consumed by the conversation.
    bot_id string Bot ID.
    total int Number of conversations returned.

    Error Response

    Field Type Description
    code int Error code.
    message string Error details.

    Error Codes

    Code Message
    40000 Invalid parameter
    20059 Bot deleted

    Get Conversation Message Records

    Get all message records within a specified conversation ID.

    Request Method

    GET

    Request URL

    https://api.gptbots.ai/v1/messages

    Authentication

    See API Overview for authentication details.

    Request

    Example Request

    curl -X GET 'https://api.gptbots.ai/v1/messages?conversation_id=xxxxxx&user_id=123456&page=1&page_size=100' \ -H 'Authorization: Bearer your_apikey' \ -H 'Content-Type: application/json'
              curl -X GET 'https://api.gptbots.ai/v1/messages?conversation_id=xxxxxx&user_id=123456&page=1&page_size=100' \
      -H 'Authorization: Bearer your_apikey' \
      -H 'Content-Type: application/json'
    
            
    This code block in the floating window

    Request Headers

    Field Type Description
    Authorization Bearer ${token} Use Authorization: Bearer ${token} for authentication. Get API key from API Key page.
    Content-Type application/json Data type, set to application/json.

    Request Body

    Field Type Required Description
    conversation_id string Yes Conversation identifier.
    page int Yes Page number to retrieve.
    page_size int Yes Number of results per page, max 100.

    Response

    Example Response

    { "total": 100, "messages": [ { "message_id": "645dd86906931c4a9e0ffb1f", "parent_message_id": "", "message_type": "ANSWER", "text": "Hello, I'm a customer service bot, please ask me anything.", "create_time": 1683871849906 }, { "message_id": "745dd86906931c4a9e0ffb1f", "parent_message_id": "645dd86906931c4a9e0ffb1f", "message_type": "QUESTION", "text": "What are the features of JPush?", "create_time": 1683871849906 }, { "message_id": "845dd86906931c4a9e0ffb1f", "parent_message_id": "745dd86906931c4a9e0ffb1f", "message_type": "ANSWER", "text": "JPush is a powerful platform...", "create_time": 1683871849906 } ] }
              {
      "total": 100,
      "messages": [
        {
          "message_id": "645dd86906931c4a9e0ffb1f",
          "parent_message_id": "",
          "message_type": "ANSWER", 
          "text": "Hello, I'm a customer service bot, please ask me anything.",
          "create_time": 1683871849906
        },
        {  
          "message_id": "745dd86906931c4a9e0ffb1f",
          "parent_message_id": "645dd86906931c4a9e0ffb1f",
          "message_type": "QUESTION",
          "text": "What are the features of JPush?",
          "create_time": 1683871849906
        },
        {
          "message_id": "845dd86906931c4a9e0ffb1f",
          "parent_message_id": "745dd86906931c4a9e0ffb1f",
          "message_type": "ANSWER",
          "text": "JPush is a powerful platform...",
          "create_time": 1683871849906
        }
      ] 
    }
    
            
    This code block in the floating window

    Successful Response

    Field Type Description
    total string Total number of messages in conversation.
    messages JSON Array Message details.
    message_id string Unique message ID.
    parent_message_id string ID of parent message.
    message_type string Message type, ANSWER or QUESTION.
    text string Message text.
    create_time long Timestamp message was created.

    Failed Response

    Field Type Description
    code int Error code.
    message string Error details.

    Error Codes

    Code Message
    40000 Invalid parameter.
    40005 Page number exceeds total.
    40127 Authentication failed.
    40356 Conversation does not exist.
    20059 Bot deleted