export type CreateApiAiagentsSendMessageArgs = {threadId: string, message: string}; export type CreateApiAiagentsSendMessageOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sends a message to the specified thread. * This method ensures that the message is delivered * according to the provided parameters, including thread and message data. * * POST /aiagents/SendMessage */ export const createApiAiagentsSendMessage = async (args: CreateApiAiagentsSendMessageArgs, options?: CreateApiAiagentsSendMessageOptions) => { const {baseUrl = "https://sb2api.servicechannel.com/v3", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.threadId != null) query.append("threadId", String(args.threadId)) if (args.message != null) query.append("message", String(args.message)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/aiagents/SendMessage${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };