2
0

📝 Add new start and continue endpoints in the API runtime instructions

This commit is contained in:
Baptiste Arnaud
2023-11-24 08:00:34 +01:00
parent 0856c59b50
commit 993bc7900e
2 changed files with 18 additions and 32 deletions

View File

@ -18,22 +18,12 @@ export const ApiPreviewInstructions = (props: StackProps) => {
const startParamsBody = startPreviewAtGroup
? `{
"startParams": {
"typebot": "${typebot?.id}",
"isPreview": true,
"startGroupId": "${startPreviewAtGroup}"
}
}`
: `{
"startParams": {
"typebot": "${typebot?.id}",
"isPreview": true
}
}`
: undefined
const replyBody = `{
"message": "This is my reply",
"sessionId": "<ID_FROM_FIRST_RESPONSE>"
}`
return (
@ -60,12 +50,16 @@ export const ApiPreviewInstructions = (props: StackProps) => {
<CodeEditor
isReadOnly
lang={'shell'}
value={`${parseApiHost(
typebot?.customDomain
)}/api/v2/sendMessage`}
value={`${parseApiHost(typebot?.customDomain)}/api/v1/typebots/${
typebot?.id
}/preview/startChat`}
/>
<Text>with the following JSON body:</Text>
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
{startPreviewAtGroup && (
<>
<Text>with the following JSON body:</Text>
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
</>
)}
</Stack>
</ListItem>
<ListItem>
@ -82,7 +76,7 @@ export const ApiPreviewInstructions = (props: StackProps) => {
lang={'shell'}
value={`${parseApiHost(
typebot?.customDomain
)}/api/v2/sendMessage`}
)}/api/v1/sessions/<ID_FROM_FIRST_RESPONSE>/continueChat`}
/>
<Text>With the following JSON body:</Text>
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
@ -95,7 +89,10 @@ export const ApiPreviewInstructions = (props: StackProps) => {
</OrderedList>
<Text fontSize="sm" pl="1">
Check out the{' '}
<TextLink href="https://docs.typebot.io/api/send-a-message" isExternal>
<TextLink
href="https://docs.typebot.io/api/start-preview-chat"
isExternal
>
API reference
</TextLink>{' '}
for more information

View File

@ -27,15 +27,9 @@ export const ApiModal = ({
onClose,
}: ModalProps): JSX.Element => {
const { typebot } = useTypebot()
const startParamsBody = `{
"startParams": {
"typebot": "${publicId}",
}
}`
const replyBody = `{
"message": "This is my reply",
"sessionId": "<ID_FROM_FIRST_RESPONSE>"
}`
return (
@ -61,10 +55,8 @@ export const ApiModal = ({
lang={'shell'}
value={`${parseApiHost(
typebot?.customDomain
)}/api/v2/sendMessage`}
)}/api/v1/typebots/${publicId}/startChat`}
/>
<Text>with the following JSON body:</Text>
<CodeEditor isReadOnly lang={'json'} value={startParamsBody} />
</Stack>
</ListItem>
<ListItem>
@ -81,7 +73,7 @@ export const ApiModal = ({
lang={'shell'}
value={`${parseApiHost(
typebot?.customDomain
)}/api/v2/sendMessage`}
)}/api/v1/sessions/<ID_FROM_FIRST_RESPONSE>/continueChat`}
/>
<Text>With the following JSON body:</Text>
<CodeEditor isReadOnly lang={'json'} value={replyBody} />
@ -94,10 +86,7 @@ export const ApiModal = ({
</OrderedList>
<Text fontSize="sm" colorScheme="gray">
Check out the{' '}
<TextLink
href="https://docs.typebot.io/api/send-a-message"
isExternal
>
<TextLink href="https://docs.typebot.io/api/start-chat" isExternal>
API reference
</TextLink>{' '}
for more information