Interface Connector
-
- All Implemented Interfaces:
public interface ConnectorA 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.
-
-
Method Summary
Modifier and Type Method Description BooleanhasFeature(ConnectorFeature feature, ConnectorType targetConnectorType)Is this feature supported ? abstract Unitregister(ConnectorController controller)Registers the connector for the specified controller. Unitunregister(ConnectorController controller)Unregisters the connector. abstract Unitsend(Event event, ConnectorCallback callback, Long delayInMs)Send an event with this connector for the specified delay. BooleanstartProactiveConversation(ConnectorCallback callback, BotBus botBus)Start a proactive conversation UnitflushProactiveConversation(ConnectorCallback callback, Map<String, String> parameters)Proactively send messages to connector UnitendProactiveConversation(ConnectorCallback callback, Map<String, String> parameters)End the proactive conversation Unitnotify(ConnectorController controller, PlayerId recipientId, IntentAware intent, StoryStep<out StoryHandlerDefinition> step, Map<String, String> parameters, ActionNotificationType notificationType, Function1<Throwable, Unit> errorListener)Sends a notification to the connector. UserPreferencesloadProfile(ConnectorCallback callback, PlayerId userId)Load user preferences - default implementation returns null. UserPreferencesrefreshProfile(ConnectorCallback callback, PlayerId userId)Refresh user preferences - default implementation returns null. Function1<BotBus, ConnectorMessage>addSuggestions(CharSequence text, List<CharSequence> suggestions)Returns a ConnectorMessage with the specified list of suggestions. Function1<BotBus, ConnectorMessage>addSuggestions(ConnectorMessage message, List<CharSequence> suggestions)Updates a ConnectorMessage with the specified list of suggestions. Function1<BotBus, List<ConnectorMessage>>toConnectorMessage(MediaMessage message)Maps a MediaMessage into a ConnectorMessage. BooleancanHandleMessageFor(ConnectorType otherConnectorType)Determines if this connector can handle other connector messages. abstract ConnectorTypegetConnectorType()The type of the connector. Set<ConnectorFeature>getSupportedFeatures()BooleangetPersistProfileLoaded()-
-
Method Detail
-
hasFeature
Boolean hasFeature(ConnectorFeature feature, ConnectorType targetConnectorType)
Is this feature supported ?
-
register
abstract Unit register(ConnectorController controller)
Registers the connector for the specified controller.
-
unregister
Unit unregister(ConnectorController controller)
Unregisters the connector.
-
send
abstract Unit send(Event event, ConnectorCallback callback, Long delayInMs)
Send an event with this connector for the specified delay. End the conversation when event.metadata.lastAnswer is activated If the connector implements the proactive conversation functions, the end must take account the start of the proactive conversation
- Parameters:
event- the event to sendcallback- the initial connector callbackdelayInMs- the optional delay
-
startProactiveConversation
Boolean startProactiveConversation(ConnectorCallback callback, BotBus botBus)
Start a proactive conversation
- Parameters:
callback- the initial connector callbackbotBus- the bot bus
-
flushProactiveConversation
Unit flushProactiveConversation(ConnectorCallback callback, Map<String, String> parameters)
Proactively send messages to connector
- Parameters:
callback- the initial connector callbackparameters- the parameters to be used for a proactive response
-
endProactiveConversation
Unit endProactiveConversation(ConnectorCallback callback, Map<String, String> parameters)
End the proactive conversation
- Parameters:
callback- the initial connector callbackparameters- the parameters to be used for a proactive response
-
notify
Unit notify(ConnectorController controller, PlayerId recipientId, IntentAware intent, StoryStep<out StoryHandlerDefinition> step, Map<String, String> parameters, ActionNotificationType notificationType, Function1<Throwable, Unit> errorListener)
Sends a notification to the connector. A BotBus is created and the corresponding story is called.
- Parameters:
controller- the connector controllerrecipientId- the recipient identifierintent- the notification intentstep- the optional step targetparameters- the optional parametersnotificationType- notification type if anyerrorListener- called when a message has not been delivered
-
loadProfile
UserPreferences loadProfile(ConnectorCallback callback, PlayerId userId)
Load user preferences - default implementation returns null.
-
refreshProfile
UserPreferences refreshProfile(ConnectorCallback callback, PlayerId userId)
Refresh user preferences - default implementation returns null. Only not null values are taken into account.
-
addSuggestions
Function1<BotBus, ConnectorMessage> addSuggestions(CharSequence text, List<CharSequence> suggestions)
Returns a ConnectorMessage with the specified list of suggestions. If the connector does not support suggestions, returns null.
-
addSuggestions
Function1<BotBus, ConnectorMessage> addSuggestions(ConnectorMessage message, List<CharSequence> suggestions)
Updates a ConnectorMessage with the specified list of suggestions. Default returns message unmodified.
-
toConnectorMessage
Function1<BotBus, List<ConnectorMessage>> toConnectorMessage(MediaMessage message)
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.
-
canHandleMessageFor
Boolean canHandleMessageFor(ConnectorType otherConnectorType)
Determines if this connector can handle other connector messages.
-
getConnectorType
abstract ConnectorType getConnectorType()
The type of the connector.
-
getSupportedFeatures
Set<ConnectorFeature> getSupportedFeatures()
-
getPersistProfileLoaded
Boolean getPersistProfileLoaded()
-
-
-
-