tock / ai.tock.bot.definition

Package ai.tock.bot.definition

Contains all classes used to define a bot

Types

BotAnswerInterceptor

Change or update answer before sending to the user Need to be registered using ai.tock.bot.engine.BotRepository.registerBotAnswerInterceptor.

interface BotAnswerInterceptor

BotDefinition

The main interface used to define the behaviour of the bot.

interface BotDefinition : I18nKeyProvider

BotDefinitionBase

Base implementation of BotDefinition.

open class BotDefinitionBase : BotDefinition

BotProvider

Provides a specific type of BotDefinition. Custom provider should usually not directly extend this class, but instead extend BotProviderBase.

interface BotProvider

BotProviderBase

Base implementation of BotProvider

open class BotProviderBase : BotProvider

BotProviderId

A BotProvider unique identifier.

data class BotProviderId

ConfigurableStoryHandler

A story handler that can be fully configured. Advanced usage only.

open class ConfigurableStoryHandler<out T : StoryHandlerDefinition> : StoryHandlerBase<T>

ConnectorDef

typealias ConnectorDef<T> = ConnectorStoryHandlerBase<T>

ConnectorHandlerProvider

Provides ConnectorHandler.

interface ConnectorHandlerProvider

ConnectorStoryHandler

Handler for specific ConnectorType.

interface ConnectorStoryHandler<out T : StoryHandlerDefinition> : BotBus

ConnectorStoryHandlerBase

Base implementation of ConnectorStoryHandler.

abstract class ConnectorStoryHandlerBase<out T : StoryHandlerDefinition> : BotBus, ConnectorStoryHandler<T>

DialogFlowDefinition

data class DialogFlowDefinition

DialogFlowState

data class DialogFlowState

DialogFlowStateTransition

data class DialogFlowStateTransition

DialogFlowStateTransitionType

enum class DialogFlowStateTransitionType

EmptyData

Convenient placeholder for empty data.

object EmptyData

EntityStepSelection

A step entity configuration option.

data class EntityStepSelection

EventListener

Listen all events - this is the standard process to handle Event that are not Action (when you need to handle them).

interface EventListener

EventListenerBase

Base implementation of EventListener.

open class EventListenerBase : EventListener

Handler

typealias Handler<T> = StoryHandlerBase<T>

HandlerDef

typealias HandlerDef<T> = StoryHandlerDefinitionBase<T>

HandlerStoryDefinitionCreator

In order to create StoryHandlerDefinition.

interface HandlerStoryDefinitionCreator<T : StoryHandlerDefinition>

Intent

An intent definition.

data class Intent : IntentAware

IntentAware

Convenient interface used to compare Intent with StoryDefinition.

interface IntentAware

IntentAwareBase

For Enum based IntentAware implementations.

interface IntentAwareBase : IntentAware

IntentDef

typealias IntentDef = IntentAwareBase

IntentWithoutNamespace

The non qualified name of the intent.

data class IntentWithoutNamespace

ParameterKey

A parameter key - the implementation is usually an enum.

interface ParameterKey

Parameters

Use ParameterKey to create this class.

data class Parameters

SimpleBotDefinition

A simple BotDefinition.

class SimpleBotDefinition : BotDefinitionBase

SimpleHandler

typealias SimpleHandler = SimpleStoryHandlerBase

SimpleStoryDefinition

Simple implementation of StoryDefinition.

open class SimpleStoryDefinition : StoryDefinition

SimpleStoryHandlerBase

For simple stories that do not use custom StoryHandlerDefinition.

abstract class SimpleStoryHandlerBase : StoryHandlerBase<StoryHandlerDefinition>

SimpleStoryStep

StoryStep without custom StoryHandlerDefinition.

interface SimpleStoryStep : StoryStep<StoryHandlerDefinition>

StoryDataStep

A step that can have specific preconditions and can use input data object in handler.

interface StoryDataStep<T : StoryHandlerDefinition, TD, D> : StoryStep<T>

StoryDataStepBase

Base class for StoryDataStep implementations.

abstract class StoryDataStepBase<T : StoryHandlerDefinition, TD, D> : StoryDataStep<T, TD, D>

StoryDefinition

The definition of a "Story". A story holds a list of actions of the same domain. The story provides a set of starter intents. When theses intents are detected, The story is started.

interface StoryDefinition : IntentAware

StoryDefinitionBase

Default StoryDefinition implementation.

open class StoryDefinitionBase : StoryDefinition

StoryDefinitionExtended

Helper methods for StoryDefinition implementation. Usually direct implementations are enums. This interface add a starter (and main) intent with intent name equals to the property of value name to the StoryDefinition. Warning: advanced usage only.

interface StoryDefinitionExtended : StoryDefinition

StoryHandler

Receive a sentence or action, and send the answer.

interface StoryHandler

StoryHandlerBase

Base implementation of StoryHandler. Provides also a convenient implementation of I18nKeyProvider to support i18n.

abstract class StoryHandlerBase<out T : StoryHandlerDefinition> : StoryHandler, I18nKeyProvider, IntentAware

StoryHandlerDefinition

Story handler definitions are used in StoryHandler to provide custom context and to manage specific connector behaviour.

interface StoryHandlerDefinition : BotBus

StoryHandlerDefinitionBase

Base implementation of StoryHandlerDefinition.

abstract class StoryHandlerDefinitionBase<T : ConnectorStoryHandlerBase<*>> : BotBus, StoryHandlerDefinition

StoryHandlerListener

To listen before and after action handling. Need to be registered using ai.tock.bot.engine.BotRepository.registerStoryHandlerListener.

interface StoryHandlerListener

StoryStep

A step is a part of a StoryDefinition. Used to manage workflow in a StoryHandler.

interface StoryStep<T : StoryHandlerDefinition>

StoryTag

enum class StoryTag

TestBehaviour

Define values and behaviour for integration tests.

interface TestBehaviour

TestBehaviourBase

Base implementation of TestBehaviour.

open class TestBehaviourBase : TestBehaviour

Properties

noStep

Use this step when you want to set a null StoryStep.

val noStep: SimpleStoryStep

Functions

bot

Creates a new bot.

fun bot(botId: String, stories: List<StoryDefinition>, namespace: String = "app", nlpModelName: String = botId, unknownStory: StoryDefinition = defaultUnknownStory, hello: IntentAware? = null, goodbye: IntentAware? = null, noInput: IntentAware? = null, botDisabled: IntentAware? = null, botEnabled: IntentAware? = null, userLocation: IntentAware? = null, handleAttachment: IntentAware? = null, eventListener: EventListener = EventListenerBase(), keywordStory: StoryDefinition = defaultKeywordStory, conversation: DialogFlowDefinition? = null): SimpleBotDefinition

defaultHandlerStoryDefinitionCreator

Returns default HandlerStoryDefinitionCreator.

fun <T : StoryHandlerDefinition> defaultHandlerStoryDefinitionCreator(): HandlerStoryDefinitionCreator<T>

notify

Sends a notification to a connector. A Bus is created and the corresponding story is called.

fun notify(applicationId: String, namespace: String, botId: String, recipientId: PlayerId, intent: IntentAware, step: StoryStep<out StoryHandlerDefinition>? = null, parameters: Parameters = Parameters.EMPTY, stateModifier: NotifyBotStateModifier = NotifyBotStateModifier.KEEP_CURRENT_STATE, notificationType: ActionNotificationType? = null, errorListener: (Throwable) -> Unit = {}): Unit

story

Creates a new story.

fun story(handler: SimpleStoryHandlerBase, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null): StoryDefinitionBase
fun story(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null, handler: BotBus.() -> Unit): StoryDefinitionBase
fun <T : StoryHandlerDefinition> story(handler: StoryHandlerBase<T>, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null): StoryDefinitionBase

Creates a new story from a StoryHandler.

fun story(intent: IntentAware, storyHandler: StoryHandler, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null): StoryDefinitionBase

storyDef

Creates a new story.

fun <T : StoryHandlerDefinition, D> storyDef(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null, handlerDefCreator: HandlerStoryDefinitionCreator<T> = defaultHandlerStoryDefinitionCreator(), preconditionsChecker: BotBus.() -> D): StoryDefinitionBase
fun <T : StoryHandlerDefinition> storyDef(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), steps: List<StoryStep<out StoryHandlerDefinition>> = emptyList(), unsupportedUserInterface: UserInterfaceType? = null, handlerDefCreator: HandlerStoryDefinitionCreator<T> = defaultHandlerStoryDefinitionCreator(), preconditionsChecker: BotBus.() -> Unit): StoryDefinitionBase

storyDefWithSteps

Creates a new story.

fun <T : StoryHandlerDefinition, S, D> storyDefWithSteps(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), unsupportedUserInterface: UserInterfaceType? = null, handlerDefCreator: HandlerStoryDefinitionCreator<T> = defaultHandlerStoryDefinitionCreator(), preconditionsChecker: BotBus.() -> D): StoryDefinitionBase where S : Enum<S>, S : StoryStep<out StoryHandlerDefinition>
fun <T : StoryHandlerDefinition, S> storyDefWithSteps(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), unsupportedUserInterface: UserInterfaceType? = null, handlerDefCreator: HandlerStoryDefinitionCreator<T> = defaultHandlerStoryDefinitionCreator(), preconditionsChecker: BotBus.() -> Unit): StoryDefinitionBase where S : Enum<S>, S : StoryStep<out StoryHandlerDefinition>

storyWithSteps

Creates a new story from a StoryHandlerBase.

fun <T> storyWithSteps(handler: StoryHandlerBase<*>, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), unsupportedUserInterface: UserInterfaceType? = null): StoryDefinitionBase where T : Enum<T>, T : StoryStep<out StoryHandlerDefinition>

Creates a new story from a StoryHandler.

fun <T> storyWithSteps(intent: IntentAware, storyHandler: StoryHandler, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), unsupportedUserInterface: UserInterfaceType? = null): StoryDefinitionBase where T : Enum<T>, T : StoryStep<out StoryHandlerDefinition>

Creates a new story.

fun <T> storyWithSteps(intentName: String, otherStarterIntents: Set<IntentAware> = emptySet(), secondaryIntents: Set<IntentAware> = emptySet(), unsupportedUserInterface: UserInterfaceType? = null, handler: BotBus.() -> Unit): StoryDefinitionBase where T : Enum<T>, T : StoryStep<out StoryHandlerDefinition>