2
0

🐛 (webhook) Fix getResultSample when linked typebot not found

Closes #364
This commit is contained in:
Baptiste Arnaud
2023-03-08 09:59:39 +01:00
parent 83ae81ccc6
commit 167d366d55

View File

@ -39,13 +39,16 @@ export const parseResultExample =
const extractLinkedInputBlocks = const extractLinkedInputBlocks =
( (
typebot: Pick<Typebot | PublicTypebot, 'groups' | 'variables' | 'edges'>, typebot:
| Pick<Typebot | PublicTypebot, 'groups' | 'variables' | 'edges'>
| undefined,
linkedTypebots: (Typebot | PublicTypebot)[] linkedTypebots: (Typebot | PublicTypebot)[]
) => ) =>
async ( async (
currentGroupId?: string, currentGroupId?: string,
direction: 'backward' | 'forward' = 'backward' direction: 'backward' | 'forward' = 'backward'
): Promise<InputBlock[]> => { ): Promise<InputBlock[]> => {
if (!typebot) return []
const previousLinkedTypebotBlocks = walkEdgesAndExtract( const previousLinkedTypebotBlocks = walkEdgesAndExtract(
'linkedBot', 'linkedBot',
direction, direction,
@ -63,7 +66,7 @@ const extractLinkedInputBlocks =
'typebotId' in t 'typebotId' in t
? t.typebotId === linkedBot.options.typebotId ? t.typebotId === linkedBot.options.typebotId
: t.id === linkedBot.options.typebotId : t.id === linkedBot.options.typebotId
) as Typebot | PublicTypebot, ),
linkedTypebots linkedTypebots
)(linkedBot.options.groupId, 'forward') )(linkedBot.options.groupId, 'forward')
) )