public BotBus extends Bus<T>
A new bus instance is created for each user request.
The bus is used by bot implementations to reply to the user request.
@NotNull BotDefinition getBotDefinition()
The bot definition of the current bot.
@NotNull UserTimeline getUserTimeline()
The user timeline. Gets history and data about the user.
@NotNull Dialog getDialog()
The current dialog history for this user.
@NotNull Story getStory()
The current story.
void setStory(@NotNull
Story p)
The current story.
@NotNull Action getAction()
The user action.
@NotNull ConnectorData getConnectorData()
The data specific to the connector (if any).
@NotNull UserPreferences getUserPreferences()
User preferences of the current user.
@NotNull Connector getUnderlyingConnector()
The underlying interface Connector used.
Please do not use this method as it is exposed for third party libraries only.
interface Connector@NotNull java.util.Map<java.lang.String,ai.tock.bot.engine.dialog.EntityStateValue> getEntities()
The entities in the dialog state.
@NotNull ai.tock.translator.I18nKeyProvider getI18nProvider()
To manage i18n.
void setI18nProvider(@NotNull
ai.tock.translator.I18nKeyProvider p)
To manage i18n.
@Nullable NextUserActionState getNextUserActionState()
Qualify the next user action.
void setNextUserActionState(@Nullable
NextUserActionState p)
Qualify the next user action.
@Nullable StoryStep<? extends ai.tock.bot.definition.StoryHandlerDefinition> getStep()
void setStep(@Nullable
StoryStep<? extends ai.tock.bot.definition.StoryHandlerDefinition> step)
@Nullable java.lang.String getStepName()
The name of the step if any.
@Nullable java.lang.String getUserText()
The text sent by the user if any.
boolean isIntent(@NotNull
IntentAware intentOwner)
To know if the current intent is owned by the interface IntentAware.
interface IntentAware@Nullable NlpCallStats nlpStats()
Returns the NLP call stats if an NLP call has occurred, null either.
boolean isChoiceAction()
Is this current action is a class SendChoice?
class SendChoice@Nullable
java.lang.String choice(@NotNull
ParameterKey key)
Returns the value of the specified choice parameter, null if the user action is not a class SendChoice
or if this parameter is not set.
class SendChoiceboolean booleanChoice(@NotNull
ParameterKey key)
Returns true if the specified choice parameter has the "true" value, false either.
boolean hasChoiceValue(@NotNull
ParameterKey param,
@NotNull
ParameterKey value)
Checks that the specified choice parameter has the specified value.
boolean hasActionEntity(@NotNull
java.lang.String role)
Returns true if the current action has the specified entity role.
boolean hasActionEntity(@NotNull
ai.tock.nlp.api.client.model.Entity entity)
Returns true if the current action has the specified entity role.
@Nullable <T extends Value> T entityValue(@NotNull java.lang.String role, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.engine.dialog.EntityValue,? extends T> valueTransformer)
Returns the current value for the specified entity role.
@Nullable <T extends Value> T entityValue(@NotNull ai.tock.nlp.api.client.model.Entity entity, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.engine.dialog.EntityValue,? extends T> valueTransformer)
Returns the current value for the specified entity.
@Nullable
java.lang.String entityText(@NotNull
ai.tock.nlp.api.client.model.Entity entity)
Returns the current text content for the specified entity.
@Nullable
java.lang.String entityText(@NotNull
java.lang.String role)
Returns the current text content for the specified entity.
@Nullable EntityValue entityValueDetails(@NotNull ai.tock.nlp.api.client.model.Entity entity)
Returns the current class EntityValue for the specified entity.
class EntityValue@Nullable EntityValue entityValueDetails(@NotNull java.lang.String role)
Returns the current class EntityValue for the specified role.
class EntityValuevoid changeEntityValue(@NotNull
java.lang.String role,
@Nullable
EntityValue newValue)
Updates the current entity value in the dialog.
role - entity rolenewValue - the new entity valuevoid changeEntityValue(@NotNull
ai.tock.nlp.api.client.model.Entity entity,
@Nullable
ai.tock.nlp.entity.Value newValue)
Updates the current entity value in the dialog.
entity - the entity definitionnewValue - the new entity valuevoid changeEntityValue(@NotNull
ai.tock.nlp.api.client.model.Entity entity,
@NotNull
EntityValue newValue)
Updates the current entity value in the dialog.
entity - the entity definitionnewValue - the new entity valuevoid changeEntityText(@NotNull
ai.tock.nlp.api.client.model.Entity entity,
@Nullable
java.lang.String textContent)
Updates the current entity text value in the dialog.
entity - the entity definitiontextContent - the new entity text contentvoid removeEntityValue(@NotNull
java.lang.String role)
Removes entity value for the specified role.
void removeEntityValue(@NotNull
ai.tock.nlp.api.client.model.Entity entity)
Removes entity value for the specified role.
void removeAllEntityValues()
Removes all current entity values.
void resetDialogState()
Resets all entity values, context values, ai.tock.bot.engine.dialog.DialogState.userLocation and ai.tock.bot.engine.dialog.DialogState.nextActionState but keep entity values history.
@Nullable
<T> T contextValue(@NotNull
java.lang.String name)
Returns the persistent current context value.
@Nullable
<T> T contextValue(@NotNull
ParameterKey key)
Returns the persistent current context value.
void changeContextValue(@NotNull
java.lang.String name,
@Nullable
java.lang.Object value)
Updates persistent context value. Do not store Collection or Map in the context, only plain objects or typed arrays.
void changeContextValue(@NotNull
ParameterKey key,
@Nullable
java.lang.Object value)
Updates persistent context value.
@Nullable
<T> T getBusContextValue(@NotNull
java.lang.String name)
Returns the non persistent current context value. Bus context values are useful to store a temporary (ie request scoped) state.
@Nullable
<T> T getBusContextValue(@NotNull
ParameterKey key)
Returns the non persistent current context value. Bus context values are useful to store a temporary (ie request scoped) state.
void setBusContextValue(@NotNull
java.lang.String key,
@Nullable
java.lang.Object value)
Updates the non persistent current context value. Bus context values are useful to store a temporary (ie request scoped) state.
void setBusContextValue(@NotNull
ParameterKey key,
@Nullable
java.lang.Object value)
Updates the non persistent current context value. Bus context values are useful to store a temporary (ie request scoped) state.
@NotNull BotBus endRawText(@Nullable java.lang.CharSequence plainText, long delay)
Sends text that should not be translated as last bot answer.
@NotNull BotBus end(@NotNull Message message, long delay)
Sends interface Message as last bot answer.
interface Message@NotNull BotBus end(@NotNull Action action, long delay)
Sends class Action as last bot answer.
class Action@NotNull BotBus end(@NotNull MessagesList messages, long initialDelay)
Sends a class MessagesList and end the dialog.
class MessagesList@NotNull BotBus send(@NotNull Message message, long delay)
Sends a interface Message.
interface Message@NotNull BotBus send(@NotNull MessagesList messages, long initialDelay)
Sends a class MessagesList.
class MessagesList@NotNull BotBus send(@NotNull Action action, long delay)
Sends an class Action.
class Action@NotNull BotBus withPriority(@NotNull ActionPriority priority)
Adds the specified enum ActionPriority to the bus context.
enum ActionPriority@NotNull BotBus withNotificationType(@NotNull ActionNotificationType notificationType)
Adds the specified enum ActionNotificationType to the bus context.
enum ActionNotificationType@NotNull BotBus withVisibility(@NotNull ActionVisibility visibility)
Adds the specified enum ActionVisibility to the bus context.
enum ActionVisibilityvoid reloadProfile()
Reloads the user profile.
void switchStory(@NotNull
StoryDefinition storyDefinition,
@NotNull
Intent starterIntent)
Switches the context to the specified story definition (start a new class Story).
class Storyvoid handleAndSwitchStory(@NotNull
StoryDefinition storyDefinition,
@NotNull
Intent starterIntent)
Handles the action and switches the context to the specified story definition.
void skipAnswer()
Does not send an answer. Synchronous interface Connectors (like Google Assistant or Alexa)
usually do not support skipping answer.
interface Connectorboolean isFeatureEnabled(@NotNull
FeatureType feature,
boolean p)
Is the feature enabled?
feature - the feature to checkp - the default value if the feature state is unknownvoid markAsUnknown()
Marks the current as not understood in the nlp model.
@NotNull
ai.tock.translator.I18nLabelValue i18n(@NotNull
java.lang.CharSequence defaultLabel,
@NotNull
java.util.List<? extends java.lang.Object> args)
@NotNull
ai.tock.translator.I18nLabelValue i18nKey(@NotNull
java.lang.String key,
@NotNull
java.lang.CharSequence defaultLabel,
@NotNull
java.lang.Object... args)
Gets an i18n label with the specified key.
@Nullable java.lang.String getContextId()
The current context identifier.
long defaultDelay(int answerIndex)
Get the default delay between two answers.
boolean getTest()
Is it a test mode ?
@NotNull BotBus end(long delay, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.engine.BotBus,? extends java.lang.Object> messageProvider)
Sends messages provided by messageProvider as last bot answer.
if messageProvider returns a CharSequence send it as text. Else call simply end().
messageProvider,
messageProvider,
CharSequence@NotNull BotBus send(long delay, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.engine.BotBus,? extends java.lang.Object> messageProvider)
Sends messages provided by messageProvider.
if messageProvider returns a CharSequence send it as text. Else call simply send().
messageProvider,
messageProvider,
CharSequence@NotNull BotBus withMessage(@NotNull ConnectorMessage message)
Adds the specified interface ConnectorMessage to the bus context if the targetConnectorType is compatible.
interface ConnectorMessage,
targetConnectorType@NotNull BotBus send(long delay)
Sends previously registered interface ConnectorMessage.
interface ConnectorMessage@NotNull BotBus send(@NotNull java.lang.CharSequence i18nText, long delay, @NotNull java.lang.Object... i18nArgs)
Sends i18nText.
@NotNull BotBus send(@NotNull java.lang.CharSequence i18nText, @NotNull java.lang.Object... i18nArgs)
Sends i18nText.
@NotNull BotBus end(@NotNull java.lang.CharSequence i18nText, long delay, @NotNull java.lang.Object... i18nArgs)
Sends i18nText as last bot answer.
@NotNull BotBus end(@NotNull java.lang.CharSequence i18nText, @NotNull java.lang.Object... i18nArgs)
Sends i18nText as last bot answer.
@NotNull BotBus end(long delay)
Send previously registered interface ConnectorMessage as last bot answer.
interface ConnectorMessage