2023-02-22 07:46:30 +01:00
|
|
|
import { guessApiHost } from '@/utils/guessApiHost'
|
2023-03-15 08:35:16 +01:00
|
|
|
import type { ChatReply, SendMessageInput } from '@typebot.io/schemas'
|
|
|
|
import { isNotEmpty, sendRequest } from '@typebot.io/lib'
|
2022-12-22 17:02:34 +01:00
|
|
|
|
2023-04-03 18:14:32 +02:00
|
|
|
export const sendMessageQuery = ({
|
2022-12-22 17:02:34 +01:00
|
|
|
apiHost,
|
|
|
|
...body
|
2023-04-03 18:14:32 +02:00
|
|
|
}: SendMessageInput & { apiHost?: string }) =>
|
|
|
|
sendRequest<ChatReply>({
|
2022-12-22 17:02:34 +01:00
|
|
|
method: 'POST',
|
2023-02-22 07:46:30 +01:00
|
|
|
url: `${isNotEmpty(apiHost) ? apiHost : guessApiHost()}/api/v1/sendMessage`,
|
2022-12-22 17:02:34 +01:00
|
|
|
body,
|
|
|
|
})
|