Send Sina Message
Sends a message to an existing Sina chat session.
Request
const response = await sendSinaMessage("Hello, how are you?", "session-123");
Response Example
{
"status": 201,
"data": {
"userMessage": {
"id": 1,
"sender": "user",
"text": "Hello, how are you?",
"chatId": "session-123",
"createdAt": "2024-03-20T10:00:00Z",
"updatedAt": "2024-03-20T10:00:00Z",
"media": null,
"data": null
},
"sinaMessage": {
"id": 2,
"sender": "sina",
"text": "I'm doing well, thank you! How can I help you today?",
"chatId": "session-123",
"createdAt": "2024-03-20T10:00:01Z",
"updatedAt": "2024-03-20T10:00:01Z",
"media": null,
"data": {
"contentType": "text",
"foundInRag": false,
"links": []
}
}
}
}
Error Handling
The function will throw an error if the API request fails. The error will contain the full response object as a string.
Example
try {
const response = await sendSinaMessage("Hello", "session-123");
} catch (error) {
console.error('Failed to send message:', error);
}