🚸 (bot) Avoid waiting for blocks with no returned data
This commit is contained in:
@ -58,7 +58,7 @@ export const BlockNode = ({
|
|||||||
setFocusedGroupId,
|
setFocusedGroupId,
|
||||||
previewingEdge,
|
previewingEdge,
|
||||||
} = useGraph()
|
} = useGraph()
|
||||||
const { mouseOverBlock, setMouseOverBlock, draggedItem } = useBlockDnd()
|
const { mouseOverBlock, setMouseOverBlock } = useBlockDnd()
|
||||||
const { typebot, updateBlock } = useTypebot()
|
const { typebot, updateBlock } = useTypebot()
|
||||||
const [isConnecting, setIsConnecting] = useState(false)
|
const [isConnecting, setIsConnecting] = useState(false)
|
||||||
const [isPopoverOpened, setIsPopoverOpened] = useState(
|
const [isPopoverOpened, setIsPopoverOpened] = useState(
|
||||||
@ -105,7 +105,7 @@ export const BlockNode = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
if (draggedItem !== undefined)
|
if (mouseOverBlock?.id !== block.id)
|
||||||
setMouseOverBlock({ id: block.id, ref: blockRef })
|
setMouseOverBlock({ id: block.id, ref: blockRef })
|
||||||
if (connectingIds)
|
if (connectingIds)
|
||||||
setConnectingIds({
|
setConnectingIds({
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
"path": "node_modules/cz-emoji"
|
"path": "node_modules/cz-emoji"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@7.14.0"
|
"packageManager": "pnpm@7.16.1"
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ if (window.$chatwoot) {
|
|||||||
})(document, "script");
|
})(document, "script");
|
||||||
}`
|
}`
|
||||||
|
|
||||||
export const executeChatwootBlock = async (
|
export const executeChatwootBlock = (
|
||||||
block: ChatwootBlock,
|
block: ChatwootBlock,
|
||||||
{ variables, isPreview, onNewLog }: IntegrationState
|
{ variables, isPreview, onNewLog }: IntegrationState
|
||||||
) => {
|
) => {
|
||||||
@ -74,7 +74,7 @@ export const executeChatwootBlock = async (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
await func(...variables.map((v) => parseCorrectValueType(v.value)))
|
func(...variables.map((v) => parseCorrectValueType(v.value)))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ export const executeGoogleSheetBlock = async (
|
|||||||
if (!('action' in block.options)) return block.outgoingEdgeId
|
if (!('action' in block.options)) return block.outgoingEdgeId
|
||||||
switch (block.options.action) {
|
switch (block.options.action) {
|
||||||
case GoogleSheetsAction.INSERT_ROW:
|
case GoogleSheetsAction.INSERT_ROW:
|
||||||
await insertRowInGoogleSheets(block.options, context)
|
insertRowInGoogleSheets(block.options, context)
|
||||||
break
|
break
|
||||||
case GoogleSheetsAction.UPDATE_ROW:
|
case GoogleSheetsAction.UPDATE_ROW:
|
||||||
await updateRowInGoogleSheets(block.options, context)
|
updateRowInGoogleSheets(block.options, context)
|
||||||
break
|
break
|
||||||
case GoogleSheetsAction.GET:
|
case GoogleSheetsAction.GET:
|
||||||
await getRowFromGoogleSheets(block.options, context)
|
await getRowFromGoogleSheets(block.options, context)
|
||||||
@ -33,7 +33,7 @@ export const executeGoogleSheetBlock = async (
|
|||||||
return block.outgoingEdgeId
|
return block.outgoingEdgeId
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertRowInGoogleSheets = async (
|
const insertRowInGoogleSheets = (
|
||||||
options: GoogleSheetsInsertRowOptions,
|
options: GoogleSheetsInsertRowOptions,
|
||||||
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
||||||
) => {
|
) => {
|
||||||
@ -46,30 +46,31 @@ const insertRowInGoogleSheets = async (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const params = stringify({ resultId })
|
const params = stringify({ resultId })
|
||||||
const { error } = await sendRequest({
|
sendRequest({
|
||||||
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
credentialsId: options.credentialsId,
|
credentialsId: options.credentialsId,
|
||||||
values: parseCellValues(options.cellsToInsert, variables),
|
values: parseCellValues(options.cellsToInsert, variables),
|
||||||
},
|
},
|
||||||
})
|
}).then(({ error }) => {
|
||||||
onNewLog(
|
onNewLog(
|
||||||
parseLog(
|
parseLog(
|
||||||
error,
|
error,
|
||||||
'Succesfully inserted a row in the sheet',
|
'Succesfully inserted a row in the sheet',
|
||||||
'Failed to insert a row in the sheet'
|
'Failed to insert a row in the sheet'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateRowInGoogleSheets = async (
|
const updateRowInGoogleSheets = (
|
||||||
options: GoogleSheetsUpdateRowOptions,
|
options: GoogleSheetsUpdateRowOptions,
|
||||||
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
||||||
) => {
|
) => {
|
||||||
if (!options.cellsToUpsert || !options.referenceCell) return
|
if (!options.cellsToUpsert || !options.referenceCell) return
|
||||||
const params = stringify({ resultId })
|
const params = stringify({ resultId })
|
||||||
const { error } = await sendRequest({
|
sendRequest({
|
||||||
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: {
|
body: {
|
||||||
@ -80,14 +81,15 @@ const updateRowInGoogleSheets = async (
|
|||||||
value: parseVariables(variables)(options.referenceCell.value ?? ''),
|
value: parseVariables(variables)(options.referenceCell.value ?? ''),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}).then(({ error }) => {
|
||||||
onNewLog(
|
onNewLog(
|
||||||
parseLog(
|
parseLog(
|
||||||
error,
|
error,
|
||||||
'Succesfully updated a row in the sheet',
|
'Succesfully updated a row in the sheet',
|
||||||
'Failed to update a row in the sheet'
|
'Failed to update a row in the sheet'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRowFromGoogleSheets = async (
|
const getRowFromGoogleSheets = async (
|
||||||
|
@ -4,7 +4,7 @@ import { parseLog } from '@/utils/helpers'
|
|||||||
import { SendEmailBlock } from 'models'
|
import { SendEmailBlock } from 'models'
|
||||||
import { sendRequest, byId } from 'utils'
|
import { sendRequest, byId } from 'utils'
|
||||||
|
|
||||||
export const executeSendEmailBlock = async (
|
export const executeSendEmailBlock = (
|
||||||
block: SendEmailBlock,
|
block: SendEmailBlock,
|
||||||
{
|
{
|
||||||
variables,
|
variables,
|
||||||
@ -25,7 +25,7 @@ export const executeSendEmailBlock = async (
|
|||||||
return block.outgoingEdgeId
|
return block.outgoingEdgeId
|
||||||
}
|
}
|
||||||
const { options } = block
|
const { options } = block
|
||||||
const { error } = await sendRequest({
|
sendRequest({
|
||||||
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
|
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
@ -43,9 +43,11 @@ export const executeSendEmailBlock = async (
|
|||||||
isBodyCode: options.isBodyCode,
|
isBodyCode: options.isBodyCode,
|
||||||
resultValues,
|
resultValues,
|
||||||
},
|
},
|
||||||
|
}).then(({ error }) => {
|
||||||
|
onNewLog(
|
||||||
|
parseLog(error, 'Succesfully sent an email', 'Failed to send an email')
|
||||||
|
)
|
||||||
})
|
})
|
||||||
onNewLog(
|
|
||||||
parseLog(error, 'Succesfully sent an email', 'Failed to send an email')
|
|
||||||
)
|
|
||||||
return block.outgoingEdgeId
|
return block.outgoingEdgeId
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ export const executeIntegration = ({
|
|||||||
}: {
|
}: {
|
||||||
block: IntegrationBlock
|
block: IntegrationBlock
|
||||||
context: IntegrationState
|
context: IntegrationState
|
||||||
}): Promise<string | undefined> => {
|
}): Promise<string | undefined> | string | undefined => {
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case IntegrationBlockType.GOOGLE_SHEETS:
|
case IntegrationBlockType.GOOGLE_SHEETS:
|
||||||
return executeGoogleSheetBlock(block, context)
|
return executeGoogleSheetBlock(block, context)
|
||||||
|
@ -25,6 +25,6 @@ export const executeLogic = async (
|
|||||||
case LogicBlockType.CODE:
|
case LogicBlockType.CODE:
|
||||||
return { nextEdgeId: await executeCode(block, context) }
|
return { nextEdgeId: await executeCode(block, context) }
|
||||||
case LogicBlockType.TYPEBOT_LINK:
|
case LogicBlockType.TYPEBOT_LINK:
|
||||||
return await executeTypebotLink(block, context)
|
return executeTypebotLink(block, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user