我正在使用https://chatbase.com/api/messages Chatbase API将多个消息发送到Chatbase。 documentation统计信息表明,响应将为请求中发送的各个消息提供错误和成功。
如果响应中的一条消息有错误,我应该如何从请求中提供的3条消息中检测出哪条消息失败?
用于发送多条消息的JSON请求正文
{
"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响应正文
{
"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
}
答案 0 :(得分:0)
错误消息的顺序将与您提交的消息的顺序相对应。在这种情况下,它是第一条消息和第三条消息。我还注意到您在时间戳中没有使用unix毫秒。消息之间的间隔至少应为一毫秒,以便在Chatbase报告中对其进行正确排序。