2
0

⚗️ Implement bot v2 MVP (#194)

Closes #190
This commit is contained in:
Baptiste Arnaud
2022-12-22 17:02:34 +01:00
committed by GitHub
parent e55823e011
commit 1a3869ae6d
202 changed files with 8060 additions and 1152 deletions

View File

@ -0,0 +1,28 @@
import { InitialChatReply, SendMessageInput, StartParams } from 'models'
import { getViewerUrl, sendRequest } from 'utils'
export async function getInitialChatReplyQuery({
typebotId,
isPreview,
apiHost,
prefilledVariables,
}: StartParams & {
apiHost?: string
}) {
if (!typebotId)
throw new Error('Typebot ID is required to get initial messages')
const response = await sendRequest<InitialChatReply>({
method: 'POST',
url: `${apiHost ?? getViewerUrl()}/api/v1/sendMessage`,
body: {
startParams: {
isPreview,
typebotId,
prefilledVariables,
},
} satisfies SendMessageInput,
})
return response.data
}

View File

@ -0,0 +1,15 @@
import { ChatReply, SendMessageInput } from 'models'
import { getViewerUrl, sendRequest } from 'utils'
export async function sendMessageQuery({
apiHost,
...body
}: SendMessageInput & { apiHost?: string }) {
const response = await sendRequest<ChatReply>({
method: 'POST',
url: `${apiHost ?? getViewerUrl()}/api/v1/sendMessage`,
body,
})
return response.data
}