-
- All Implemented Interfaces:
-
ai.tock.bot.connector.Connector
public final class MessengerConnector extends ConnectorBaseContains built-in checks to ensure that two MessageRequest for the same recipient are sent sequentially.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classMessengerConnector.Companion
-
Field Summary
Fields Modifier and Type Field Description private final ConnectorTypeconnectorTypeprivate final BooleanpersistProfileLoadedprivate final Set<ConnectorFeature>supportedFeatures
-
Method Summary
Modifier and Type Method Description Unitregister(ConnectorController controller)Unitunregister(ConnectorController controller)final SendResponsesendEvent(Event event, Function1<MessageRequest, MessageRequest> transformMessageRequest, Function1<String, Unit> postMessage, Function1<ActionRequest, ActionRequest> transformActionRequest, Function1<Throwable, Unit> errorListener)Send an action to messenger. final UnitsendOptInEvent(Event event)Send action after an optin request, using the recipient.user_ref property. final UnitsendCustomEvent(CustomEventRequest customEventRequest)Send a custom event to messenger final StringgetThreadOwner(PlayerId userId)Returns the current thread owner (handover protocol). final List<SecondaryReceiverData>getSecondaryReceivers()Returns the secondary receivers (handover protocol) if the app is the primary receiver, null either. final SendResponserequestThreadControl(PlayerId userId, String metadata)Sends a request to get thread control. final SendResponsetakeThreadControl(PlayerId userId, String metadata)Takes the thread control. final SendResponsepassThreadControl(PlayerId userId, String targetAppId, String metadata)Passes thread control. Unitsend(Event event, ConnectorCallback callback, Long delayInMs)Send the event to messenger asynchronously. UserPreferencesloadProfile(ConnectorCallback callback, PlayerId userId)UserPreferencesrefreshProfile(ConnectorCallback callback, PlayerId userId)Unitnotify(ConnectorController controller, PlayerId recipientId, IntentAware intent, StoryStep<out StoryHandlerDefinition> step, Map<String, String> parameters, ActionNotificationType notificationType, Function1<Throwable, Unit> errorListener)Function1<BotBus, ConnectorMessage>addSuggestions(CharSequence text, List<CharSequence> suggestions)Function1<BotBus, ConnectorMessage>addSuggestions(ConnectorMessage message, List<CharSequence> suggestions)Function1<BotBus, List<ConnectorMessage>>toConnectorMessage(MediaMessage message)-
Methods inherited from class ai.tock.bot.connector.ConnectorBase
getConnectorType, getSupportedFeatures, toString -
Methods inherited from class ai.tock.bot.connector.Connector
canHandleMessageFor, getPersistProfileLoaded, hasFeature -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
unregister
Unit unregister(ConnectorController controller)
-
sendEvent
final SendResponse sendEvent(Event event, Function1<MessageRequest, MessageRequest> transformMessageRequest, Function1<String, Unit> postMessage, Function1<ActionRequest, ActionRequest> transformActionRequest, Function1<Throwable, Unit> errorListener)
Send an action to messenger.
- Parameters:
event- the action to sendtransformMessageRequest- method to transform the MessageRequest before sending - default is identitypostMessage- method (with token parameter) launched after successful MessageRequest call - default do nothingtransformActionRequest- method to transform the ActionRequest before sending - default is identity
-
sendOptInEvent
@Deprecated(message = "deprecated - use BotRepository#notify") final Unit sendOptInEvent(Event event)
Send action after an optin request, using the recipient.user_ref property. See https://developers.facebook.com/docs/messenger-platform/plugin-reference/checkbox-plugin#implementation for more details.
-
sendCustomEvent
final Unit sendCustomEvent(CustomEventRequest customEventRequest)
Send a custom event to messenger
- Parameters:
customEventRequest- an object containing a list of custom events
-
getThreadOwner
final String getThreadOwner(PlayerId userId)
Returns the current thread owner (handover protocol).
- Parameters:
userId- the user id you would like to known
-
getSecondaryReceivers
final List<SecondaryReceiverData> getSecondaryReceivers()
Returns the secondary receivers (handover protocol) if the app is the primary receiver, null either.
-
requestThreadControl
final SendResponse requestThreadControl(PlayerId userId, String metadata)
Sends a request to get thread control.
-
takeThreadControl
final SendResponse takeThreadControl(PlayerId userId, String metadata)
Takes the thread control.
-
passThreadControl
final SendResponse passThreadControl(PlayerId userId, String targetAppId, String metadata)
Passes thread control.
-
send
Unit send(Event event, ConnectorCallback callback, Long delayInMs)
Send the event to messenger asynchronously. Contains checks to ensure that two Action for the same recipient are sent sequentially.
-
loadProfile
UserPreferences loadProfile(ConnectorCallback callback, PlayerId userId)
-
refreshProfile
UserPreferences refreshProfile(ConnectorCallback callback, PlayerId userId)
-
notify
Unit notify(ConnectorController controller, PlayerId recipientId, IntentAware intent, StoryStep<out StoryHandlerDefinition> step, Map<String, String> parameters, ActionNotificationType notificationType, Function1<Throwable, Unit> errorListener)
-
addSuggestions
Function1<BotBus, ConnectorMessage> addSuggestions(CharSequence text, List<CharSequence> suggestions)
-
addSuggestions
Function1<BotBus, ConnectorMessage> addSuggestions(ConnectorMessage message, List<CharSequence> suggestions)
-
toConnectorMessage
Function1<BotBus, List<ConnectorMessage>> toConnectorMessage(MediaMessage message)
-
-
-
-