2022-11-29 10:02:40 +01:00
|
|
|
import { executeChatwootBlock } from '@/features/blocks/integrations/chatwoot/api'
|
|
|
|
|
import { executeGoogleAnalyticsBlock } from '@/features/blocks/integrations/googleAnalytics/api'
|
|
|
|
|
import { executeGoogleSheetBlock } from '@/features/blocks/integrations/googleSheets/api'
|
2023-03-09 08:46:36 +01:00
|
|
|
import { executeOpenAIBlock } from '@/features/blocks/integrations/openai/executeOpenAIBlock'
|
2022-11-29 10:02:40 +01:00
|
|
|
import { executeSendEmailBlock } from '@/features/blocks/integrations/sendEmail/api'
|
|
|
|
|
import { executeWebhookBlock } from '@/features/blocks/integrations/webhook/api'
|
|
|
|
|
import { IntegrationBlock, IntegrationBlockType, SessionState } from 'models'
|
|
|
|
|
import { ExecuteIntegrationResponse } from '../../types'
|
|
|
|
|
|
|
|
|
|
export const executeIntegration =
|
2023-01-27 10:54:59 +01:00
|
|
|
(state: SessionState, lastBubbleBlockId?: string) =>
|
2022-11-29 10:02:40 +01:00
|
|
|
async (block: IntegrationBlock): Promise<ExecuteIntegrationResponse> => {
|
|
|
|
|
switch (block.type) {
|
|
|
|
|
case IntegrationBlockType.GOOGLE_SHEETS:
|
|
|
|
|
return executeGoogleSheetBlock(state, block)
|
|
|
|
|
case IntegrationBlockType.CHATWOOT:
|
2023-01-27 10:54:59 +01:00
|
|
|
return executeChatwootBlock(state, block, lastBubbleBlockId)
|
2022-11-29 10:02:40 +01:00
|
|
|
case IntegrationBlockType.GOOGLE_ANALYTICS:
|
2023-01-27 10:54:59 +01:00
|
|
|
return executeGoogleAnalyticsBlock(state, block, lastBubbleBlockId)
|
2022-11-29 10:02:40 +01:00
|
|
|
case IntegrationBlockType.EMAIL:
|
|
|
|
|
return executeSendEmailBlock(state, block)
|
|
|
|
|
case IntegrationBlockType.WEBHOOK:
|
|
|
|
|
case IntegrationBlockType.ZAPIER:
|
|
|
|
|
case IntegrationBlockType.MAKE_COM:
|
|
|
|
|
case IntegrationBlockType.PABBLY_CONNECT:
|
|
|
|
|
return executeWebhookBlock(state, block)
|
2023-03-09 08:46:36 +01:00
|
|
|
case IntegrationBlockType.OPEN_AI:
|
|
|
|
|
return executeOpenAIBlock(state, block)
|
2022-11-29 10:02:40 +01:00
|
|
|
}
|
|
|
|
|
}
|