🚑️ Fix audio clip not saving properly
This commit is contained in:
@ -107,14 +107,16 @@ export const continueBotFlow = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
formattedReply =
|
formattedReply =
|
||||||
'reply' in parsedReplyResult ? parsedReplyResult.reply : undefined
|
'reply' in parsedReplyResult && reply?.type === 'text'
|
||||||
|
? parsedReplyResult.reply
|
||||||
|
: undefined
|
||||||
newSessionState = await processAndSaveAnswer(
|
newSessionState = await processAndSaveAnswer(
|
||||||
state,
|
state,
|
||||||
block
|
block
|
||||||
)(
|
)(
|
||||||
isDefined(formattedReply)
|
isDefined(formattedReply)
|
||||||
? { ...reply, type: 'text', text: formattedReply }
|
? { ...reply, type: 'text', text: formattedReply }
|
||||||
: undefined
|
: reply
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,9 +314,12 @@ const processAndSaveAnswer =
|
|||||||
const saveVariablesValueIfAny =
|
const saveVariablesValueIfAny =
|
||||||
(state: SessionState, block: InputBlock) =>
|
(state: SessionState, block: InputBlock) =>
|
||||||
(reply: Message): SessionState => {
|
(reply: Message): SessionState => {
|
||||||
if (!block.options?.variableId) return state
|
|
||||||
let newSessionState = saveAttachmentsVarIfAny({ block, reply, state })
|
let newSessionState = saveAttachmentsVarIfAny({ block, reply, state })
|
||||||
newSessionState = saveAudioClipVarIfAny({ block, reply, state })
|
newSessionState = saveAudioClipVarIfAny({
|
||||||
|
block,
|
||||||
|
reply,
|
||||||
|
state: newSessionState,
|
||||||
|
})
|
||||||
return saveInputVarIfAny({ block, reply, state: newSessionState })
|
return saveInputVarIfAny({ block, reply, state: newSessionState })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +384,7 @@ const saveAudioClipVarIfAny = ({
|
|||||||
return state
|
return state
|
||||||
|
|
||||||
const variable = state.typebotsQueue[0].typebot.variables.find(
|
const variable = state.typebotsQueue[0].typebot.variables.find(
|
||||||
(variable) => variable.id === block.options?.attachments?.saveVariableId
|
(variable) => variable.id === block.options?.audioClip?.saveVariableId
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!variable) return state
|
if (!variable) return state
|
||||||
@ -408,7 +413,7 @@ const saveInputVarIfAny = ({
|
|||||||
reply: Message
|
reply: Message
|
||||||
state: SessionState
|
state: SessionState
|
||||||
}): SessionState => {
|
}): SessionState => {
|
||||||
if (reply.type !== 'text') return state
|
if (reply.type !== 'text' || !block.options?.variableId) return state
|
||||||
|
|
||||||
const foundVariable = state.typebotsQueue[0].typebot.variables.find(
|
const foundVariable = state.typebotsQueue[0].typebot.variables.find(
|
||||||
(variable) => variable.id === block.options?.variableId
|
(variable) => variable.id === block.options?.variableId
|
||||||
|
Reference in New Issue
Block a user