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

View File

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