2
0

🚑️ Fix audio clip not saving properly

This commit is contained in:
Baptiste Arnaud
2024-08-20 15:11:41 +02:00
parent 135251d3f7
commit e67f3bc9e9

View File

@ -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