Skip to content

The open alternative to Salesforce, designed for AI.

1.3 KB
Raw Blame
import { randomUUID } from 'node:crypto';

import gql from 'graphql-tag';
import { TEST_AI_MODEL_ID } from 'test/integration/constants/test-ai-model-ids.constants';

export const sendChatParticipationMessageOperationFactory = ({
  threadId,
  messageId = randomUUID(),
  text = 'Can you help with this task?',
  modelId = TEST_AI_MODEL_ID,
  shouldAssistantReply = true,
  mentionedWorkspaceMemberIds = [],
}: {
  threadId: string;
  messageId?: string;
  text?: string;
  modelId?: string;
  shouldAssistantReply?: boolean;
  mentionedWorkspaceMemberIds?: string[];
}) => ({
  query: gql`
    mutation SendParticipationMessage(
      $threadId: UUID!
      $messageId: UUID!
      $text: String!
      $modelId: String
      $shouldAssistantReply: Boolean
      $mentionedWorkspaceMemberIds: [UUID!]
    ) {
      sendChatMessage(
        threadId: $threadId
        messageId: $messageId
        text: $text
        modelId: $modelId
        shouldAssistantReply: $shouldAssistantReply
        mentionedWorkspaceMemberIds: $mentionedWorkspaceMemberIds
      ) {
        messageId
        queued
        streamId
        mentionedParticipantWorkspaceMemberIds
      }
    }
  `,
  variables: {
    threadId,
    messageId,
    text,
    modelId,
    shouldAssistantReply,
    mentionedWorkspaceMemberIds,
  },
});