@ebonydevcopy/framework
Version:
A module-based NodeJS chatbot framework.
66 lines • 2.28 kB
TypeScript
import PostbackRouter from './routers/PostbackRouter';
import ReferralsRouter from './routers/ReferralsRouter';
import TextMatcher from './routers/TextMatcher';
import { GenericAttachment } from './interfaces/attachment';
import { WitNLP } from './interfaces/nlp';
import { ISerializable } from '.';
import { IInteraction } from './interfaces/interactions';
import { ITrackingData } from './interfaces/trackingData';
export interface IRouters {
PostbackRouter?: PostbackRouter;
ReferralsRouter?: ReferralsRouter;
TextMatcher?: TextMatcher;
}
export interface EbonyHandlers<U> {
attachment?: (user: U, attachment: GenericAttachment) => Promise<any>;
text?: (message: {
text: string;
tracking_data?: ITrackingData;
location?: {
lon: number;
lat: number;
};
}, nlp: WitNLP | undefined, user: U) => Promise<any>;
}
export interface IBaseMessageOptions {
delay?: number;
schedule?: number;
priority?: number;
}
export interface IBaseMessage<T extends IBaseMessageOptions> {
type: 'message' | 'typing_on' | 'typing_off' | 'mark_seen' | 'notify';
id: string;
message?: ISerializable;
options?: Partial<T>;
}
export default abstract class GenericAdapter<Operations = {
handover: (id: string) => Promise<any>;
}> {
protected handlers: EbonyHandlers<any>;
protected routers: IRouters;
abstract operations: Operations;
abstract sender: (actions: Array<IInteraction<any>>, type: 'ORDERED' | 'UNORDERED') => Promise<void>;
constructor();
setRouters(routers: IRouters): void;
setHandlers<U>(handlers: EbonyHandlers<U>): void;
abstract initialization(): void;
init<U>(routers: InitOptionsRouters, handlers: InitOptionsHandlers<U>): void;
}
interface InitOptionsRouters {
postbackRouter: PostbackRouter;
referralsRouter: ReferralsRouter;
textMatcher: TextMatcher;
}
interface InitOptionsHandlers<U> {
text: (message: {
text: string;
tracking_data?: ITrackingData;
location?: {
lon: number;
lat: number;
};
}, nlp: WitNLP | undefined, user: U) => any;
attachment: (user: U, attachment: GenericAttachment) => Promise<any>;
}
export {};
//# sourceMappingURL=adapter.d.ts.map