2022-11-15 14:59:34 +01:00
|
|
|
import { executeChatwootBlock } from '@/features/blocks/integrations/chatwoot'
|
|
|
|
|
import { executeGoogleAnalyticsBlock } from '@/features/blocks/integrations/googleAnalytics'
|
|
|
|
|
import { executeGoogleSheetBlock } from '@/features/blocks/integrations/googleSheets'
|
|
|
|
|
import { executeSendEmailBlock } from '@/features/blocks/integrations/sendEmail'
|
|
|
|
|
import { executeWebhook } from '@/features/blocks/integrations/webhook'
|
|
|
|
|
import { IntegrationState } from '@/types'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { IntegrationBlock, IntegrationBlockType } from '@typebot.io/schemas'
|
2022-11-15 14:59:34 +01:00
|
|
|
|
|
|
|
|
export const executeIntegration = ({
|
|
|
|
|
block,
|
|
|
|
|
context,
|
|
|
|
|
}: {
|
|
|
|
|
block: IntegrationBlock
|
|
|
|
|
context: IntegrationState
|
2022-11-16 15:21:09 +01:00
|
|
|
}): Promise<string | undefined> | string | undefined => {
|
2022-11-15 14:59:34 +01:00
|
|
|
switch (block.type) {
|
|
|
|
|
case IntegrationBlockType.GOOGLE_SHEETS:
|
|
|
|
|
return executeGoogleSheetBlock(block, context)
|
|
|
|
|
case IntegrationBlockType.GOOGLE_ANALYTICS:
|
|
|
|
|
return executeGoogleAnalyticsBlock(block, context)
|
|
|
|
|
case IntegrationBlockType.ZAPIER:
|
|
|
|
|
case IntegrationBlockType.MAKE_COM:
|
|
|
|
|
case IntegrationBlockType.PABBLY_CONNECT:
|
|
|
|
|
case IntegrationBlockType.WEBHOOK:
|
|
|
|
|
return executeWebhook(block, context)
|
|
|
|
|
case IntegrationBlockType.EMAIL:
|
|
|
|
|
return executeSendEmailBlock(block, context)
|
|
|
|
|
case IntegrationBlockType.CHATWOOT:
|
|
|
|
|
return executeChatwootBlock(block, context)
|
2023-03-03 15:03:31 +01:00
|
|
|
default:
|
|
|
|
|
return
|
2022-11-15 14:59:34 +01:00
|
|
|
}
|
|
|
|
|
}
|