feat: Enable agents to initiate conversations with connected users and refactor the conversation start flow to be role-aware.
This commit is contained in:
@@ -34,7 +34,7 @@ interface UseMessagingReturn {
|
||||
disconnect: () => void;
|
||||
loadConversations: () => Promise<void>;
|
||||
selectConversation: (conversationId: string) => Promise<void>;
|
||||
startConversation: (agentProfileId: string) => Promise<Conversation>;
|
||||
startConversation: (body: { agentProfileId?: string; userId?: string }) => Promise<Conversation>;
|
||||
sendMessage: (content: string, messageType?: MessageType, fileFields?: { fileUrl?: string; mimeType?: string; fileName?: string; fileSize?: number }) => Promise<void>;
|
||||
loadMoreMessages: () => Promise<void>;
|
||||
startTyping: () => void;
|
||||
@@ -163,10 +163,10 @@ export function useMessaging(options: UseMessagingOptions = {}): UseMessagingRet
|
||||
[isConnected]
|
||||
);
|
||||
|
||||
// Start a new conversation with an agent
|
||||
// Start a new conversation with an agent (for users) or a user (for agents)
|
||||
const startConversation = useCallback(
|
||||
async (agentProfileId: string): Promise<Conversation> => {
|
||||
const conversation = await messagesService.startConversation(agentProfileId);
|
||||
async (body: { agentProfileId?: string; userId?: string }): Promise<Conversation> => {
|
||||
const conversation = await messagesService.startConversation(body);
|
||||
|
||||
// Add to conversations list if not exists
|
||||
setConversations((prev) => {
|
||||
|
||||
Reference in New Issue
Block a user