2
0
Files
bot/packages/embeds/js/src/queries/sendMessageQuery.ts
2023-04-03 18:14:32 +02:00

14 lines
428 B
TypeScript

import { guessApiHost } from '@/utils/guessApiHost'
import type { ChatReply, SendMessageInput } from '@typebot.io/schemas'
import { isNotEmpty, sendRequest } from '@typebot.io/lib'
export const sendMessageQuery = ({
apiHost,
...body
}: SendMessageInput & { apiHost?: string }) =>
sendRequest<ChatReply>({
method: 'POST',
url: `${isNotEmpty(apiHost) ? apiHost : guessApiHost()}/api/v1/sendMessage`,
body,
})