tock / ai.tock.bot.connector / Connector

Connector

interface Connector (source)

A connector connects bots to users via a dedicated interface (like Messenger, Google Assistant, Slack... ).

There is one Connector for each user front-end application. See ai.tock.bot.connector.messenger.MessengerConnector or ai.tock.bot.connector.ga.GAConnector for examples of Connector implementations.

Properties

connectorType

The type of the connector.

abstract val connectorType: ConnectorType

supportedFeatures

Supported features.

open val supportedFeatures: Set<ConnectorFeature>

Functions

addSuggestions

Returns a ConnectorMessage with the specified list of suggestions. If the connector does not support suggestions, returns null.

open fun addSuggestions(text: CharSequence, suggestions: List<CharSequence>): BotBus.() -> ConnectorMessage?

Updates a ConnectorMessage with the specified list of suggestions. Default returns message unmodified.

open fun addSuggestions(message: ConnectorMessage, suggestions: List<CharSequence>): BotBus.() -> ConnectorMessage?

hasFeature

Is this feature supported ?

open fun hasFeature(feature: ConnectorFeature, targetConnectorType: ConnectorType): Boolean

loadProfile

Load user preferences - default implementation returns null.

open fun loadProfile(callback: ConnectorCallback, userId: PlayerId): UserPreferences?

notify

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

open fun notify(controller: ConnectorController, recipientId: PlayerId, intent: IntentAware, step: StoryStep<out StoryHandlerDefinition>? = null, parameters: Map<String, String> = emptyMap(), notificationType: ActionNotificationType?, errorListener: (Throwable) -> Unit = {}): Unit

refreshProfile

Refresh user preferences - default implementation returns null. Only not null values are taken into account.

open fun refreshProfile(callback: ConnectorCallback, userId: PlayerId): UserPreferences?

register

Registers the connector for the specified controller.

abstract fun register(controller: ConnectorController): Unit

send

Send an event with this connector for the specified delay.

abstract fun send(event: Event, callback: ConnectorCallback, delayInMs: Long = 0): Unit

toConnectorMessage

Maps a MediaMessage into a ConnectorMessage. If toConnectorMessage returns an empty list, the mapping is not supported for this connector. Default returns an empty list.

open fun toConnectorMessage(message: MediaMessage): BotBus.() -> List<ConnectorMessage>

unregister

Unregisters the connector.

open fun unregister(controller: ConnectorController): Unit

Inheritors

ConnectorBase

Base implementation of Connector. Connector implementations should usually extend this class.

abstract class ConnectorBase : Connector