0

I'm using https://chatbase.com/api/messages Chatbase API to send multiple messages to the Chatbase. The documentation stats that the response would provide error and success for individual messages that are sent in the request.

How I should detect which message is failed out of the 3 messages that I have provided in the request if the response provides error for one message?

JSON Request body for sending multiple messages

{
    "messages": [
        {
            "api_key": "<API KEY>",
            "type": "agent",
            "user_id": "User_1",
            "time_stamp": 1542895834,
            "platform": "XXX",
            "message": "Test 1",
            "not_handled": false,
            "version": "1.0",
            "session_id": "session-User_1"
        },
        {
            "api_key": "<API KEY>",
            "type": "agent",
            "user_id": "User_1",
            "time_stamp": 1542895834,
            "platform": "XXX",
            "message": "Test 2",
            "not_handled": false,
            "version": "1.0",
            "session_id": "session-User_1"
        },
        {
            "api_key": "<API KEY>",
            "type": "agent",
            "user_id": "User_1",
            "time_stamp": 1542895834,
            "platform": "XXX",
            "message": "Test 3",
            "not_handled": false,
            "version": "1.0",
            "session_id": "session-User_1"
        }
    ]
}

JSON Response body

{
    "all_succeeded": false,
    "responses": [
        {
            "error": "Error fetching parameter 'type': Invalid conversation type [dfg]",
            "status": "error"
        },
        {
            "message_id": 139429278,
            "status": "success"
        },
        {
            "error": "Error fetching parameter 'time_stamp': Received a time (1921-02-09 09:49:26) which was too small. Please send a time within the past day for metrics to appear in the dashboards, or omit the time_stamp field for the time to automatically be set to now.",
            "status": "error"
        }
    ],
    "status": 200
}

1 Answers1

0

The order of the error messages will correspond to the order of the messages you submitted. In this case, it was the first and third messages. I also noticed that you are not using unix milliseconds in your timestamps. The messages will need to be at least one millisecond apart in order to sort them correctly in the Chatbase reports.

Sean Pearson
  • 261
  • 1
  • 6