Skip to main content

Get or Initialize Chat by Group ID

This endpoint retrieves (or creates) an AI-powered chat session tied to a specific group.
Each chat is connected to a vectorized knowledge base, enabling contextual discussions about group-related video content.

Endpoint

GET /api/chatembed/:group_id

Authentication

Required.
Only authenticated users can access or initialize AI chat sessions.

Parameters

Path Parameters

ParameterTypeRequiredDescription
group_idstringYesThe ID of the group for which the AI chat should be retrieved or initialized

Response

Success Response

Code: 200 OK

Content Example:

{
"aiChat": {
"id": 92,
"GroupId": 42,
"UserId": 123,
"title": "Group Chat",
"createdAt": "2026-02-12T16:31:22.000Z",
"updatedAt": "2026-02-12T16:31:22.000Z"
},
"messages": [
{
"id": 101,
"message": "Welcome back! What would you like to discuss today?",
"agent": "ai",
"isAI": true,
"UserId": 123,
"createdAt": "2026-02-12T16:31:22.000Z",
"user": {
"id": 123,
"username": "Leon",
"name": "Leon"
}
}
],
"createdNewChat": false
}

Error Response

Code: 500 Internal Server Error

Content Example:

{ "error": "Failed to retrieve or initialize chat" }

Notes

  • If a chat for the user and group already exists, it is returned along with its full message history.
  • If no chat exists, one is automatically created (AIChat.findOrCreate).
  • Messages include both user and AI agent entries, ordered chronologically.
  • This endpoint does not yet expose direct access to the Vector Database; rather, it uses embeddings internally to provide context-aware responses.

Example

curl -X GET "https://api.tribesocial.io/api/chatembed/42" \
-H "Authorization: Bearer <token>"

Would you like me to add a future endpoints section placeholder at the bottom of the overview.md (e.g., "Upcoming: Semantic Search API, Video Concept Explorer") for consistency with your roadmap-style docs?