Skip to content

Commit

Permalink
🐛 (calCom) Don't delete session if chat reply has custom embed
Browse files Browse the repository at this point in the history
Closes #1164
  • Loading branch information
baptisteArno committed Jan 22, 2024
1 parent 233e993 commit 5627105
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions apps/viewer/src/features/chat/api/continueChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export const continueChat = publicProcedure
logs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

const isPreview = isNotDefined(session.state.typebotsQueue[0].resultId)
Expand Down
6 changes: 6 additions & 0 deletions apps/viewer/src/features/chat/api/legacy/sendMessageV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export const sendMessageV1 = publicProcedure
logs: allLogs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down Expand Up @@ -187,6 +190,9 @@ export const sendMessageV1 = publicProcedure
logs: allLogs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down
6 changes: 6 additions & 0 deletions apps/viewer/src/features/chat/api/legacy/sendMessageV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export const sendMessageV2 = publicProcedure
logs: allLogs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down Expand Up @@ -186,6 +189,9 @@ export const sendMessageV2 = publicProcedure
logs: allLogs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down
3 changes: 3 additions & 0 deletions apps/viewer/src/features/chat/api/startChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export const startChat = publicProcedure
logs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down
3 changes: 3 additions & 0 deletions apps/viewer/src/features/chat/api/startChatPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const startChatPreview = publicProcedure
logs,
clientSideActions,
visitedEdges,
hasCustomEmbedBubble: messages.some(
(message) => message.type === 'custom-embed'
),
})

return {
Expand Down
6 changes: 5 additions & 1 deletion packages/bot-engine/saveStateToDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Props = {
clientSideActions: ContinueChatResponse['clientSideActions']
visitedEdges: VisitedEdge[]
forceCreateSession?: boolean
hasCustomEmbedBubble?: boolean
}

export const saveStateToDatabase = async ({
Expand All @@ -25,12 +26,15 @@ export const saveStateToDatabase = async ({
clientSideActions,
forceCreateSession,
visitedEdges,
hasCustomEmbedBubble,
}: Props) => {
const containsSetVariableClientSideAction = clientSideActions?.some(
(action) => action.expectsDedicatedReply
)

const isCompleted = Boolean(!input && !containsSetVariableClientSideAction)
const isCompleted = Boolean(
!input && !containsSetVariableClientSideAction && !hasCustomEmbedBubble
)

const resultId = state.typebotsQueue[0].resultId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export const CustomEmbedBubble = (props: Props) => {
let containerRef: HTMLDivElement | undefined

onMount(() => {
console.log(
props.content.initFunction.content,
props.content.initFunction.args
)
executeCode({
args: {
...props.content.initFunction.args,
Expand Down

1 comment on commit 5627105

@vercel
Copy link

@vercel vercel bot commented on 5627105 Jan 22, 2024

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
builder-v2-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.