Skip to content

Commit

Permalink
📝 Add new start and continue endpoints in the API runtime instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 24, 2023
1 parent 0856c59 commit 993bc79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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>
Expand All @@ -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} />
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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>
Expand All @@ -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} />
Expand All @@ -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
Expand Down

1 comment on commit 993bc79

@vercel
Copy link

@vercel vercel bot commented on 993bc79 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.