Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/base-types/src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum NodeType {
ZAPIER = 'zapier',
INTEGRATIONS = 'integrations',
GOOGLE_SHEETS = 'google_sheets',
CUSTOM = 'custom',

// advanced
INTENT = 'intent',
Expand Down
38 changes: 38 additions & 0 deletions packages/base-types/src/node/custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Nullable } from '@voiceflow/common';

import { NodeType } from './constants';
import { BaseEvent, BaseNode, BasePort, BasePortList, BaseStep, BaseStepPorts, NodeID } from './utils';

export interface StepData<Payload = unknown> {
stop?: boolean;
payload: Payload;
defaultPath?: number;
}

export interface StepPort<Event = BaseEvent> extends BasePort {
data: { event?: Event };
}

export interface StepPorts<Event> extends BaseStepPorts<Record<string, StepPort<Event>>, StepPort<Event>[]> {}

export interface Step<Payload = unknown, Event = BaseEvent> extends BaseStep<StepData<Payload>, StepPorts<Event>, BasePortList<StepPort<Event>>> {
type: NodeType.CUSTOM;
}

export interface NodePath<Event = BaseEvent> {
label?: string;
event?: Event;
nextID: Nullable<NodeID>;
}

export interface NodePayload {
name: string;
body: unknown;
}

export interface Node<Event = BaseEvent> extends BaseNode {
stop: boolean;
paths: Array<NodePath<Event>>;
payload: NodePayload;
defaultPath?: number; // index starting from 0
}
8 changes: 6 additions & 2 deletions packages/base-types/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as _v1 from './_v1';
import * as Api from './api';
import * as Code from './code';
import * as Component from './component';
import * as Custom from './custom';
import * as Exit from './exit';
import * as Flow from './flow';
import * as General from './general';
Expand Down Expand Up @@ -30,6 +31,7 @@ export * as Carousel from './carousel';
export * as Code from './code';
export * as Component from './component';
export * from './constants';
export * as Custom from './custom';
export * as Directive from './directive';
export * as Exit from './exit';
export * as Flow from './flow';
Expand Down Expand Up @@ -76,7 +78,8 @@ export type AnyCommonStep =
| GoTo.Step
| GoToNode.Step
| Url.Step
| _v1.Step;
| _v1.Step
| Custom.Step;

export type AnyCommonNode =
| Set.Node
Expand All @@ -93,6 +96,7 @@ export type AnyCommonNode =
| GoTo.Node
| Url.Node
| GoToNode.Node
| _v1.Node;
| _v1.Node
| Custom.Node;

export type AnyCommonCommand = Intent.Command | Command.Command;
1 change: 1 addition & 0 deletions packages/base-types/src/node/utils/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum TraceType {
CAROUSEL = 'carousel',
NO_REPLY = 'no-reply',
ENTITY_FILLING = 'entity-filling',
CUSTOM = 'custom',
}

export interface BaseTraceFramePath<Event extends BaseEvent = BaseEvent> {
Expand Down