tock / ai.tock.bot.definition / BotDefinition

# BotDefinition

`interface BotDefinition : I18nKeyProvider` (source)

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

New bots should usually not directly extend this class, but instead extend BotDefinitionBase.

### Properties

#### botDisabledStories | List of deactivation stories. `open val botDisabledStories: List<StoryDefinition>`
#### botDisabledStory | To manage deactivation. `abstract val botDisabledStory: StoryDefinition?`
#### botEnabledListener | Listener invoked when bot is enabled. `open val botEnabledListener: (Action) -> Unit`
#### botEnabledStories | List of reactivation stories. `open val botEnabledStories: List<StoryDefinition>`
#### botEnabledStory | To manage reactivation. `abstract val botEnabledStory: StoryDefinition?`
#### botId | The main bot id. Must be different for each bot. `abstract val botId: String`
#### defaultStory | Provides default Story when no context is known - default to helloStory or first stories. `open val defaultStory: StoryDefinition`
#### defaultUnknownAnswer | The default unknown answer. `abstract val defaultUnknownAnswer: I18nLabelValue`
#### eventListener | To handle custom events. `abstract val eventListener: EventListener`
#### flowDefinition | `open val flowDefinition: DialogFlowDefinition?`
#### goodbyeStory | The goodbye story. Used when closing the conversation. `abstract val goodbyeStory: StoryDefinition?`
#### handleAttachmentStory | The story that handles ai.tock.bot.engine.action.SendAttachment action. If it's null, current intent is used. `abstract val handleAttachmentStory: StoryDefinition?`
#### helloStory | The hello story. Used for first interaction with no other input. `abstract val helloStory: StoryDefinition?`
#### keywordStory | To handle keywords - used to bypass nlp. `abstract val keywordStory: StoryDefinition`
#### namespace | The namespace of the bot. It has to be the same namespace than the NLP models. `abstract val namespace: String`
#### nlpModelName | The name of the main nlp model. `abstract val nlpModelName: String`
#### noInputStory | The no input story. When user does nothing! `abstract val noInputStory: StoryDefinition?`
#### stories | The list of each stories. `abstract val stories: List<StoryDefinition>`
#### testBehaviour | Returns a TestBehaviour. Used in Integration Tests. `open val testBehaviour: TestBehaviour`
#### unknownStory | The unknown story. Used where no valid intent is found. `abstract val unknownStory: StoryDefinition`
#### userLocationStory | The story that handles ai.tock.bot.engine.action.SendLocation action. If it's null, current intent is used. `abstract val userLocationStory: StoryDefinition?`

### Functions

#### defaultDelay | Get the default delay between two answers. `open fun defaultDelay(answerIndex: Int): Long`
#### disableBot | Does this action trigger bot deactivation ? `open fun disableBot(timeline: UserTimeline, dialog: Dialog, action: Action): Boolean`
#### enableBot | Does this action trigger bot activation ? `open fun enableBot(timeline: UserTimeline, dialog: Dialog, action: Action): Boolean`
#### entity | Returns the entity with the specified name and optional role. `open fun entity(name: String, role: String? = null): Entity`
#### errorAction | Called when error occurs. By default send "technical error". `open fun errorAction(playerId: PlayerId, applicationId: String, recipientId: PlayerId): Action`
#### findIntent | Finds an Intent from an intent name. `open fun findIntent(intent: String, applicationId: String): Intent`
#### findStoryByStoryHandler | Search story by storyHandler. `open fun findStoryByStoryHandler(storyHandler: StoryHandler, applicationId: String): StoryDefinition?`
#### findStoryDefinition | Finds a StoryDefinition from an Intent. `open fun findStoryDefinition(intent: IntentAware?, applicationId: String): StoryDefinition` Finds a StoryDefinition from an intent name. `open fun findStoryDefinition(intent: String?, applicationId: String): StoryDefinition`
#### findStoryDefinitionById | Search story by storyId. `open fun findStoryDefinitionById(storyId: String, applicationId: String): StoryDefinition`
#### hasDisableTagIntent | Returns true if the dialog current intent is a disabling intent. `open fun hasDisableTagIntent(dialog: Dialog): Boolean`
#### hasToPersistAction | If this method returns true, the action will be added in the stored history. `open fun hasToPersistAction(timeline: UserTimeline, action: Action): Boolean`
#### i18n | `open fun i18n(defaultLabel: CharSequence, args: List<Any?>): I18nLabelValue`
#### i18nTranslator | Returns an I18nTranslator for the specified userLocale and connectorType. `open fun i18nTranslator(userLocale: Locale, connectorType: ConnectorType, userInterfaceType: UserInterfaceType = connectorType.userInterfaceType, contextId: String? = null): I18nTranslator`

### Companion Object Properties

#### defaultBreath | Convenient default value in ms to wait before next answer sentence. 1s by default. `var defaultBreath: Long`

### Extension Functions

#### newBusMock | Provides a mock initialized with the specified StoryDefinition. `fun BotDefinition.newBusMock(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId()): BotBusMock`
#### newBusMockContext | Provides a mock context initialized with the specified StoryDefinition. `fun BotDefinition.newBusMockContext(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId(), botId: PlayerId = PlayerId("bot", PlayerType.bot), action: Action = SendSentence(userId, this.botId, botId, ""), userInterfaceType: UserInterfaceType = UserInterfaceType.textChat, userPreferences: UserPreferences = UserPreferences(locale = locale)): BotBusMockContext`
#### startNewBusMock | Provides a mock initialized with the specified StoryDefinition and starts the story. `fun BotDefinition.startNewBusMock(testContext: TestContext = currentTestContext, story: StoryDefinition = testContext.defaultStoryDefinition(this), connectorType: ConnectorType = testContext.defaultConnectorType(), locale: Locale = testContext.defaultLocale(), userId: PlayerId = testContext.defaultPlayerId()): BotBusMock`

### Inheritors

#### BotDefinitionBase | Base implementation of BotDefinition. `open class BotDefinitionBase : BotDefinition`