@botonic/core
Version:
Runtime and APIs for Botonic bots: actions, context, messaging, and integration hooks used by the **current** framework line.
97 lines (96 loc) • 3.19 kB
TypeScript
import type { BotonicData } from '@botonic/shared';
import { MessageType } from '@botonic/shared';
export declare enum HelpdeskEvent {
StatusChanged = "status_changed",
AgentMessageCreated = "agent_message_created",
QueuePositionChanged = "queue_position_changed"
}
export declare enum InputType {
Text = "text",
Image = "image",
Video = "video",
Audio = "audio",
Document = "document",
Location = "location",
Contact = "contact",
Custom = "custom",
Raw = "raw",
CaseEventQueuePosition = "case_event_queue_position",
Postback = "postback",
Event = "event",
/** Legacy typing: maps to v2 typing event_name "typing_on". */
StartTyping = "start_typing",
/** Legacy typing: maps to v2 typing event_name "typing_off". */
SendPaused = "send_paused"
}
export declare enum NluType {
Keyword = "keyword",
SmartIntent = "smart-intent",
Intent = "intent"
}
export interface NluResolution {
type: NluType;
matchedValue: string;
payload?: string;
}
export interface CampaignV2 {
id: string;
name: string;
agent_context?: string;
end_date?: string;
}
export interface InputContext {
campaigns_v2?: CampaignV2[];
}
export type SentBy = 'enduser' | 'agent' | 'bot';
export interface BotonicRequestInput {
type: MessageType;
data: BotonicData;
provider_id?: string;
sent_by?: string;
db_id?: string;
bot_interaction_id: string;
conversation_id?: string;
context?: InputContext;
/** Bot-side: NLU resolution set by plugins. */
nluResolution?: NluResolution;
}
/**
* Facade over {@link BotonicRequestInput}: wraps the wire payload and exposes
* camelCase accessors (`text`, `botInteractionId`, …). It does not implement
* `BotonicRequestInput` (naming and shape differ on purpose).
*/
export declare class BotonicContextInput {
private rawInput;
constructor(rawInput: BotonicRequestInput);
get type(): MessageType;
get data(): BotonicData;
get providerId(): string | undefined;
get sentBy(): string | undefined;
get dbId(): string | undefined;
get botInteractionId(): string;
get conversationId(): string | undefined;
get context(): InputContext | undefined;
get nluResolution(): NluResolution | undefined;
set nluResolution(v: NluResolution | undefined);
private getKeyDataStringValue;
get text(): string | undefined;
set text(value: string);
get payload(): string | undefined;
set payload(value: string | undefined);
get referral(): string | undefined;
get attachmentUrl(): string | undefined;
get transcript(): string | undefined;
/** True when the input is text with string data present. */
hasInputText(): boolean;
/**
* Replace the current input with a synthetic postback so type and data stay in sync.
* Use for redirect flow instead of mutating payload/type/text individually.
*/
setAsPostback(payload: string): void;
/**
* Replace the current input with synthetic text so type and data stay in sync.
* Use when converting e.g. WhatsApp referral to text input.
*/
setAsText(text: string): void;
}