我正在使用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
}发布于 2019-04-12 02:50:00
错误消息的顺序将与您提交的消息的顺序相对应。在本例中,它是第一条和第三条消息。我还注意到,您的时间戳中没有使用unix毫秒。为了在Chatbase报告中正确地对消息进行排序,这些消息需要至少相隔一毫秒。
https://stackoverflow.com/questions/55608459
复制相似问题