Skip to content

Commit

Permalink
fix: remove integrations service (PL-901) (#339)
Browse files Browse the repository at this point in the history
This fully removes the integrations service. The standard behavior is for a unknown node to get captured by the `NextHandler`:
https://github.com/voiceflow/general-runtime/blob/4e455014623d48d788339953af62c4de2260c367/runtime/lib/Handlers/next.ts#L9-L16

However, this will cause breakage of the agent, as the integration node only has `node.success_id` or `node.fail_id`.

Instead there is now just a stub handler that routes it to the fail port, or whatever port.

To unblock infra, we have to remove `INTEGRATIONS_HANDLER_ENDPOINT` as a required env var.

Co-authored-by: Tyler Han <tylerhan97@gmail.com>
  • Loading branch information
DecathectZero and DecathectZero committed Apr 2, 2024
1 parent eba77d0 commit fe55e95
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 42 deletions.
3 changes: 0 additions & 3 deletions .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ AWS_REGION='localhost'
DYNAMO_ENDPOINT="http://localstack.test.e2e:8000"
SESSIONS_DYNAMO_TABLE='com.getvoiceflow.e2e.sessions'

# local configs
INTEGRATIONS_HANDLER_ENDPOINT="https://integrations.test.e2e:8009"

# mongo
MONGO_URI='mongodb://mongodb.test.e2e:27017'
MONGO_DB='main-test'
Expand Down
3 changes: 1 addition & 2 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ AWS_REGION='localhost'
DYNAMO_ENDPOINT="http://localhost:8000"
SESSIONS_DYNAMO_TABLE='com.getvoiceflow.test.sessions'
SESSIONS_SOURCE='dynamo'
INTEGRATIONS_HANDLER_ENDPOINT="http://integrations"
LOG_LEVEL='warn'
MIDDLEWARE_VERBOSITY='none'

Expand All @@ -18,4 +17,4 @@ PG_PORT='PG_PORT'

# mongo
MONGO_URI='mongodb://mongodb.test.e2e:27017'
MONGO_DB='main-test'
MONGO_DB='main-test'
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Also add the following file to the local repository:
> PORT=4000
> SESSIONS_DYNAMO_TABLE="none"
>
> INTEGRATIONS_HANDLER_ENDPOINT="none"
>
> LOG_LEVEL="debug"
> MIDDLEWARE_VERBOSITY="short"
>
Expand Down Expand Up @@ -143,7 +141,6 @@ If you want to add your own database or custom methods, feel free to look at the

These environment variables are optional and meant for specific blocks that have microservices that perform external functions. If left undefined the `code`/`API` block will run their requests locally on this server, as long as the project is trusted it is not an issue.

| name | example/values | desc | required |
| ------------------------------- | :---------------------- | ----------------------------------------------------------------------------------------------: | -------- |
| `CODE_HANDLER_ENDPOINT` | `http://localhost:8804` | stateless cloud service endpoint to execute the code block | NO |
| `INTEGRATIONS_HANDLER_ENDPOINT` | `http://localhost:8100` | cloud endpoint for zapier/google blocks - not available if `alexa-runtime` is ran as standalone | NO |
| name | example/values | desc | required |
| ----------------------- | :---------------------- | ---------------------------------------------------------: | -------- |
| `CODE_HANDLER_ENDPOINT` | `http://localhost:8804` | stateless cloud service endpoint to execute the code block | NO |
1 change: 0 additions & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const CONFIG: Config = {

DYNAMO_ENDPOINT: getOptionalProcessEnv('DYNAMO_ENDPOINT'),
CODE_HANDLER_ENDPOINT: getOptionalProcessEnv('CODE_HANDLER_ENDPOINT'),
INTEGRATIONS_HANDLER_ENDPOINT: getRequiredProcessEnv('INTEGRATIONS_HANDLER_ENDPOINT'),

// api-block
API_MAX_TIMEOUT_MS: Number(getOptionalProcessEnv('API_MAX_TIMEOUT_MS')) || null,
Expand Down
5 changes: 2 additions & 3 deletions lib/services/runtime/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import DirectiveHandler, { DirectiveResponseBuilder } from './directive';
import DisplayHandler, { DisplayResponseBuilder } from './display';
import DisplayHandlerV2 from './displayV2';
import GoToHandler from './goTo';
import IntegrationsHandler from './integrations';
import IntegrationsStubHandler from './integrations';
import InteractionHandler from './interaction';
import PaymentHandler, { PaymentResponseBuilder } from './payment';
import PermissionCardHandler, { PermissionCardResponseBuilder } from './permissionCard';
Expand All @@ -55,7 +55,6 @@ export const responseHandlers = [
const _v1Handler = _V1Handler();

export default ({
INTEGRATIONS_HANDLER_ENDPOINT,
CODE_HANDLER_ENDPOINT,
API_MAX_BODY_LENGTH_BYTES,
API_MAX_CONTENT_LENGTH_BYTES,
Expand Down Expand Up @@ -91,7 +90,7 @@ export default ({
maxResponseBodySizeBytes: API_MAX_CONTENT_LENGTH_BYTES ?? undefined,
maxRequestBodySizeBytes: API_MAX_BODY_LENGTH_BYTES ?? undefined,
}),
IntegrationsHandler({ integrationsEndpoint: INTEGRATIONS_HANDLER_ENDPOINT }),
IntegrationsStubHandler(),
RandomHandler(),
SetHandler(),
SetV2Handler(),
Expand Down
32 changes: 6 additions & 26 deletions lib/services/runtime/handlers/integrations.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import { BaseNode } from '@voiceflow/base-types';
import {
HandlerFactory,
IntegrationsHandler as GeneralRuntimeIntegrationsHandler,
} from '@voiceflow/general-runtime/build/runtime';

import log from '@/logger';

export interface IntegrationsOptions {
integrationsEndpoint: string;
}
import { HandlerFactory } from '@voiceflow/general-runtime/build/runtime';

const VALID_INTEGRATIONS = new Set([
BaseNode.Utils.IntegrationType.ZAPIER,
BaseNode.Utils.IntegrationType.GOOGLE_SHEETS,
]);

const IntegrationsHandler: HandlerFactory<BaseNode.Integration.Node, IntegrationsOptions> = ({
integrationsEndpoint,
}) => ({
// the integrations node for zapier and google sheets is no longer supported
// this is a stub handler to mitigate changes to agent behavior
const IntegrationsHandler: HandlerFactory<BaseNode.Integration.Node> = () => ({
canHandle: (node) =>
node.type === BaseNode.NodeType.INTEGRATIONS && VALID_INTEGRATIONS.has(node.selected_integration),
handle: (node, runtime, variables, programs) => {
if (node.selected_action && node.selected_integration) {
log.warn(
log.vars({
integration: node.selected_integration,
action: node.selected_action,
versionID: runtime?.getVersionID?.(),
projectID: runtime?.project?._id,
})
);
}

return GeneralRuntimeIntegrationsHandler({ integrationsEndpoint }).handle(node, runtime, variables, programs);
handle: (node) => {
return node.fail_id ?? node.success_id ?? null;
},
});

Expand Down
1 change: 0 additions & 1 deletion types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface Config {
// Application secrets
DYNAMO_ENDPOINT: string | null;
CODE_HANDLER_ENDPOINT: string | null;
INTEGRATIONS_HANDLER_ENDPOINT: string;

API_MAX_TIMEOUT_MS: number | null;
API_MAX_CONTENT_LENGTH_BYTES: number | null;
Expand Down

0 comments on commit fe55e95

Please sign in to comment.