twilly
Version:
Node.js Twilio API abstraction layer for Express applications
44 lines (43 loc) • 1.53 kB
TypeScript
import { Action, ActionContext, Trigger } from '../Actions';
import { Flow } from '../Flows';
import { TwilioWebhookRequest } from '../twllio';
export declare type FlowContext = {
[index: string]: ActionContext;
};
export declare type InteractionContext = ActionContext[];
export interface SmsCookie {
createdAt: Date;
from: string;
flow: string;
flowContext: FlowContext;
flowKey: string | number;
interactionContext: InteractionContext;
interactionComplete: boolean;
interactionId: string;
isComplete: boolean;
question: {
attempts: string[];
isAnswering: boolean;
};
}
export declare function addQuestionAttempt(state: SmsCookie, attempt: string): SmsCookie;
export declare function completeInteraction(state: SmsCookie): {
isComplete: boolean;
createdAt: Date;
from: string;
flow: string;
flowContext: FlowContext;
flowKey: string | number;
interactionContext: ActionContext[];
interactionComplete: boolean;
interactionId: string;
question: {
attempts: string[];
isAnswering: boolean;
};
};
export declare function createSmsCookie(req: TwilioWebhookRequest): SmsCookie;
export declare function handleTrigger(state: SmsCookie, trigger: Trigger): SmsCookie;
export declare function incrementFlowAction(state: SmsCookie, flow: Flow): SmsCookie;
export declare function startQuestion(state: SmsCookie): SmsCookie;
export declare function updateContext(state: SmsCookie, flow: Flow, action: Action): SmsCookie;