feat(conversations): expose inbox assistant
This commit is contained in:
@@ -783,6 +783,34 @@ func (h *ConversationHandler) ListAttachments(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"meta": gin.H{"total_count": total}, "payload": payload})
|
||||
}
|
||||
|
||||
// InboxAssistant returns the Captain assistant connected to the conversation inbox.
|
||||
// GET /api/v1/accounts/:account_id/conversations/:conversation_id/inbox_assistant
|
||||
// Reference: Chatwoot enterprise conversations_controller#inbox_assistant.
|
||||
func (h *ConversationHandler) InboxAssistant(c *gin.Context) {
|
||||
accountID, err := parseUintParam(c, "account_id")
|
||||
if err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid account_id")
|
||||
return
|
||||
}
|
||||
|
||||
conversationID, err := parseUintParam(c, "conversation_id")
|
||||
if err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid conversation_id")
|
||||
return
|
||||
}
|
||||
|
||||
assistant, svcErr := h.conversationSvc.GetInboxAssistant(c.Request.Context(), accountID, conversationID)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
}
|
||||
if assistant == nil {
|
||||
c.JSON(http.StatusOK, gin.H{"assistant": nil})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"assistant": gin.H{"id": assistant.ID, "name": assistant.Name}})
|
||||
}
|
||||
|
||||
// ToggleTyping toggles the typing status for an agent in a conversation.
|
||||
// POST /api/v1/accounts/:account_id/conversations/:id/toggle_typing_status
|
||||
// Reference: Chatwoot conversations_controller#toggle_typing_status (member route)
|
||||
|
||||
Reference in New Issue
Block a user