UNPKG

@xapp/chat-widget

Version:
174 lines (173 loc) 5.33 kB
import 'rollup-plugin-inject-process-env'; export type RequestSlotValues = string | number | object | DateTimeRange | DateTime | Duration | (string)[]; /** * Information for a slot coming in on the request. */ export interface RequestSlot<T = RequestSlotValues> { /** * The name of the slot, also used as the key in the RequestSlotMap. * * For example, "FIRST_TEAM" or "Podcast", this is typically user defined. */ name: string; /** * The slot normalized value. * * When leveraging synonyms, this will be the canonical value. If not then it is * the same as the rawValue. * * For example, "University of Virginia" or "Red Wine". */ value?: T; /** * The original value provided by the NLU before normalization. */ original?: unknown; /** * The raw spoken value. * * For example, "cavaliers" or "red" */ rawValue?: string; /** * ID of the slot, if applicable. * * For example, "UVA" */ id?: string; /** * Confidence on the slot match. Range is between 0 - 1 where 1 is the highest confidence. */ matchConfidence?: number; /** * If the entity resolution was successful or not. * * See {@link https://developer.amazon.com/docs/custom-skills/define-synonyms-and-ids-for-slot-type-values-entity-resolution.html#er-built-in-types} */ successfulMatch?: boolean; } /** * Map of slots where the key is the name of the slot. */ export interface RequestSlotMap { /** * Each key is the slot name and the corresponding value is the slot. */ [slotName: string]: RequestSlot; } export interface ResponseOutput extends Localizable<LocaleSpecificResponseOutput> { /** * The SSML */ ssml?: string; /** * Text to speech * * @deprecated Do not use, instead use both ssml and displayText */ textToSpeech?: string; /** * Used only display/chat capable surfaces */ displayText?: string; /** * Sanitized HTML, suitable for displaying within a web environment. * * This is typically generated from the displayText based on markdown found within. * * @beta */ html?: string; /** * Used where suggestions can be displayed to the user. * * Note: These only apply to prompts, not reprompts. */ suggestions?: SuggestionTypes[]; /** * The locale for the response, defaults to "en" */ defaultLocale?: Locale; /** * The language code for the response output. */ locales?: Partial<Record<Locale, LocaleSpecificResponseOutput>>; } export type SuggestionTypes = SimpleSuggestion | SuggestionObjectTypes; export type SuggestionObjectTypes = Suggestion | LinkOutSuggestion; export type SimpleSuggestion = string; /** * Suggested responses that a user can tap. * * The title has a limit of 25 characters. * * Only Google Assistant at the moment. */ export interface Suggestion { title: string; } /** * Suggestion chip that links out to an App or Website. Ownership of the * URL must be validated in the Actions on Google developer console or the suggestion will not * be shown. * * The title has a limit of 20 characters, note this is different from when * it is a normal suggestion * * Only Google Assistant at the moment. */ export interface LinkOutSuggestion extends Suggestion { url: string; } export type LocaleSpecificResponseOutput = Partial<Pick<ResponseOutput, "displayText" | "ssml" | "textToSpeech" | "suggestions">>; export interface DateTime { /** * ISO-8601 for time, in the format HH:mm:ss */ time?: string; /** * ISO-8601 for the date, in the format YYYY-MM-dd */ date?: string; /** * ISO-8601 timezone offset string in the format -05:00 or Z */ tz?: string; } export interface DateTimeRange { /** * Start of the range */ start: DateTime; /** * End of the range. */ end: DateTime; } /** * Text that describes the format of a duration, for example "years" or "M" for months. * * This is the same as the moment.js duration format. */ export type DurationFormat = "year" | "years" | "y" | "quarter" | "quarters" | "Q" | "month" | "months" | "M" | "week" | "weeks" | "w" | "day" | "days" | "d" | "hour" | "hours" | "h" | "minute" | "minutes" | "m" | "second" | "seconds" | "s" | "millisecond" | "milliseconds" | "ms"; /** * Duration, amount and format. */ export interface Duration { readonly amount: number; readonly format: DurationFormat; } export type LocaleObject = object; /** * An object that has a default locale and separate localalized versions. */ export interface Localizable<O extends LocaleObject> { defaultLocale?: Locale; locales?: Partial<Record<Locale, Partial<O>>>; } export type LanguageTag = "de-DE" | "en-AU" | "en-CA" | "en-GB" | "en-IN" | "en-US" | "es-419" | "es-ES" | "es-MX" | "fr-CA" | "fr-FR" | "it-IT" | "ja-JP" | "pt-BR" | "zh-CH" | "zh-HK" | "zh-TW"; export type Language = "da" | "de" | "en" | "es" | "fr" | "it" | "ja" | "nl" | "no" | "pt" | "ru" | "sv" | "th" | "tr" | "uk" | "zh"; /** * The different kinds of locales that can be assigned in Stentor. */ export type Locale = LanguageTag | Language;