public static class BotBus.DefaultImpls
A new bus instance is created for each user request.
The bus is used by bot implementations to reply to the user request.
@Nullable public static StoryStep<? extends ai.tock.bot.definition.StoryHandlerDefinition> getStep(BotBus $this)
public static void setStep(BotBus $this, @Nullable StoryStep<? extends ai.tock.bot.definition.StoryHandlerDefinition> step)
@Nullable public static java.lang.String getStepName(BotBus $this)
The name of the step if any.
@Nullable public static java.lang.String getUserText(BotBus $this)
The text sent by the user if any.
public static boolean isIntent(BotBus $this, @NotNull IntentAware intentOwner)
To know if the current intent is owned by the interface IntentAware.
interface IntentAware@Nullable public static NlpCallStats nlpStats(BotBus $this)
Returns the NLP call stats if an NLP call has occurred, null either.
public static boolean isChoiceAction(BotBus $this)
Is this current action is a class SendChoice?
class SendChoice@Nullable public static java.lang.String choice(BotBus $this, @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 SendChoicepublic static boolean booleanChoice(BotBus $this, @NotNull ParameterKey key)
Returns true if the specified choice parameter has the "true" value, false either.
public static boolean hasChoiceValue(BotBus $this, @NotNull ParameterKey param, @NotNull ParameterKey value)
Checks that the specified choice parameter has the specified value.
public static boolean hasActionEntity(BotBus $this, @NotNull java.lang.String role)
Returns true if the current action has the specified entity role.
public static boolean hasActionEntity(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity)
Returns true if the current action has the specified entity role.
@Nullable public static <T extends Value> T entityValue(BotBus $this, @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 public static <T extends Value> T entityValue(BotBus $this, @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 public static java.lang.String entityText(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity)
Returns the current text content for the specified entity.
@Nullable public static java.lang.String entityText(BotBus $this, @NotNull java.lang.String role)
Returns the current text content for the specified entity.
@Nullable public static EntityValue entityValueDetails(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity)
Returns the current class EntityValue for the specified entity.
class EntityValue@Nullable public static EntityValue entityValueDetails(BotBus $this, @NotNull java.lang.String role)
Returns the current class EntityValue for the specified role.
class EntityValuepublic static void changeEntityValue(BotBus $this, @NotNull java.lang.String role, @Nullable EntityValue newValue)
Updates the current entity value in the dialog.
$this - entity rolerole - the new entity valuenewValue - the new entity valuepublic static void changeEntityValue(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity, @Nullable ai.tock.nlp.entity.Value newValue)
Updates the current entity value in the dialog.
$this - the entity definitionentity - the new entity valuenewValue - the new entity valuepublic static void changeEntityValue(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity, @NotNull EntityValue newValue)
Updates the current entity value in the dialog.
$this - the entity definitionentity - the new entity valuenewValue - the new entity valuepublic static void changeEntityText(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity, @Nullable java.lang.String textContent)
Updates the current entity text value in the dialog.
$this - the entity definitionentity - the new entity text contenttextContent - the new entity text contentpublic static void removeEntityValue(BotBus $this, @NotNull java.lang.String role)
Removes entity value for the specified role.
public static void removeEntityValue(BotBus $this, @NotNull ai.tock.nlp.api.client.model.Entity entity)
Removes entity value for the specified role.
public static void removeAllEntityValues(BotBus $this)
Removes all current entity values.
public static void resetDialogState(BotBus $this)
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 public static <T> T contextValue(BotBus $this, @NotNull java.lang.String name)
Returns the persistent current context value.
@Nullable public static <T> T contextValue(BotBus $this, @NotNull ParameterKey key)
Returns the persistent current context value.
public static void changeContextValue(BotBus $this, @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.
public static void changeContextValue(BotBus $this, @NotNull ParameterKey key, @Nullable java.lang.Object value)
Updates persistent context value.
@Nullable public static <T> T getBusContextValue(BotBus $this, @NotNull ParameterKey key)
Returns the non persistent current context value. Bus context values are useful to store a temporary (ie request scoped) state.
public static void setBusContextValue(BotBus $this, @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 public static BotBus endRawText(BotBus $this, @Nullable java.lang.CharSequence plainText, long delay)
Sends text that should not be translated as last bot answer.
@NotNull public static BotBus end(BotBus $this, @NotNull Message message, long delay)
Sends interface Message as last bot answer.
interface Message@NotNull public static BotBus end(BotBus $this, @NotNull MessagesList messages, long initialDelay)
Sends a class MessagesList and end the dialog.
class MessagesList@NotNull public static BotBus send(BotBus $this, @NotNull Message message, long delay)
Sends a interface Message.
interface Message@NotNull public static BotBus send(BotBus $this, @NotNull MessagesList messages, long initialDelay)
Sends a class MessagesList.
class MessagesListpublic static void switchStory(BotBus $this, @NotNull StoryDefinition storyDefinition, @NotNull Intent starterIntent)
Switches the context to the specified story definition (start a new class Story).
class Storypublic static void handleAndSwitchStory(BotBus $this, @NotNull StoryDefinition storyDefinition, @NotNull Intent starterIntent)
Handles the action and switches the context to the specified story definition.
public static void skipAnswer(BotBus $this)
Does not send an answer. Synchronous interface Connectors (like Google Assistant or Alexa)
usually do not support skipping answer.
interface Connectorpublic static boolean isFeatureEnabled(BotBus $this, @NotNull FeatureType feature, boolean p)
Is the feature enabled?
$this - the feature to checkfeature - the default value if the feature state is unknown@NotNull public static ai.tock.translator.I18nLabelValue i18n(BotBus $this, @NotNull java.lang.CharSequence defaultLabel, @NotNull java.util.List<? extends java.lang.Object> args)
@NotNull public static ai.tock.translator.I18nLabelValue i18nKey(BotBus $this, @NotNull java.lang.String key, @NotNull java.lang.CharSequence defaultLabel, @NotNull java.lang.Object... args)
Gets an i18n label with the specified key.
@Nullable public static java.lang.String getContextId(BotBus $this)
The current context identifier.
public static long defaultDelay(BotBus $this, int answerIndex)
Get the default delay between two answers.
public static boolean getTest(BotBus $this)
Is it a test mode ?
@NotNull public static BotBus end(BotBus $this, 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 public static BotBus send(BotBus $this, 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 public static BotBus withMessage(BotBus $this, @NotNull ConnectorMessage message)
Adds the specified interface ConnectorMessage to the bus context if the targetConnectorType is compatible.
interface ConnectorMessage,
targetConnectorType@NotNull public static BotBus send(BotBus $this, long delay)
Sends previously registered interface ConnectorMessage.
interface ConnectorMessage@NotNull public static BotBus send(BotBus $this, @NotNull java.lang.CharSequence i18nText, long delay, @NotNull java.lang.Object... i18nArgs)
Sends i18nText.
@NotNull public static BotBus send(BotBus $this, @NotNull java.lang.CharSequence i18nText, @NotNull java.lang.Object... i18nArgs)
Sends i18nText.
@NotNull public static BotBus end(BotBus $this, @NotNull java.lang.CharSequence i18nText, long delay, @NotNull java.lang.Object... i18nArgs)
Sends i18nText as last bot answer.
@NotNull public static BotBus end(BotBus $this, @NotNull java.lang.CharSequence i18nText, @NotNull java.lang.Object... i18nArgs)
Sends i18nText as last bot answer.
@NotNull public static BotBus end(BotBus $this, long delay)
Send previously registered interface ConnectorMessage as last bot answer.
interface ConnectorMessage@NotNull public static ai.tock.translator.I18nLabelValue i18n(BotBus $this, @NotNull java.lang.CharSequence defaultLabel, @NotNull java.lang.Object... args)
@NotNull public static ai.tock.translator.TranslatedSequence translate(BotBus $this, @Nullable java.lang.CharSequence text, @NotNull java.lang.Object... args)
Translates and format if needed the text with the optionals args.
@NotNull public static ai.tock.translator.TranslatedSequence translate(BotBus $this, @Nullable ai.tock.translator.I18nLabelValue key)
Translates the specified key.
@Nullable public static ai.tock.translator.TranslatedSequence translateAndReturnBlankAsNull(BotBus $this, @Nullable java.lang.CharSequence s)
Translates the specified text and return null if the answer is blank.