export type CreateApiV1ExternalSupportProjectIdConversationsStartArgs = {projectId: string, body: {botId: string, userId: string, initialMessage?: string | undefined, metadata?: Record | undefined, assignment?: ({type?: string | undefined, target?: string | undefined}) | undefined}}; export type CreateApiV1ExternalSupportProjectIdConversationsStartOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start Conversation * * POST /v1/external-support/{projectId}/conversations/start */ export const createApiV1ExternalSupportProjectIdConversationsStart = async (args: CreateApiV1ExternalSupportProjectIdConversationsStartArgs, options?: CreateApiV1ExternalSupportProjectIdConversationsStartOptions) => { const {baseUrl = "https://api.jelou.ai", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("x-api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/external-support/${encodeURIComponent(String(args.projectId))}/conversations/start${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };