public class MessengerConnector
Contains built-in checks to ensure that two class MessageRequest for the same recipient are sent sequentially.
class MessageRequestpublic static ai.tock.bot.connector.messenger.MessengerConnector.Companion Companion
public void register(@NotNull
ai.tock.bot.engine.ConnectorController controller)
public void unregister(@NotNull
ai.tock.bot.engine.ConnectorController controller)
@Nullable public SendResponse sendEvent(@NotNull ai.tock.bot.engine.event.Event event, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.connector.messenger.model.send.MessageRequest,ai.tock.bot.connector.messenger.model.send.MessageRequest> transformMessageRequest, @NotNull kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> postMessage, @NotNull kotlin.jvm.functions.Function1<? super ai.tock.bot.connector.messenger.model.send.ActionRequest,ai.tock.bot.connector.messenger.model.send.ActionRequest> transformActionRequest, @NotNull kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> errorListener)
Send an action to messenger.
event - the action to sendtransformMessageRequest - method to transform the class MessageRequest before sending - default is identitypostMessage - method (with token parameter) launched after successful class MessageRequest call - default do nothingtransformActionRequest - method to transform the class ActionRequest before sending - default is identitypublic void sendOptInEvent(@NotNull
ai.tock.bot.engine.event.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.
IllegalStateException - if the message is not deliveredpublic void sendCustomEvent(@NotNull
CustomEventRequest customEventRequest)
Send a custom event to messenger
customEventRequest - an object containing a list of custom events@Nullable
public java.lang.String getThreadOwner(@NotNull
ai.tock.bot.engine.user.PlayerId userId)
Returns the current thread owner (handover protocol).
userId - the user id you would like to known@Nullable public java.util.List<ai.tock.bot.connector.messenger.model.handover.SecondaryReceiverData> getSecondaryReceivers()
Returns the secondary receivers (handover protocol) if the app is the primary receiver, null either.
@Nullable public SendResponse requestThreadControl(@NotNull ai.tock.bot.engine.user.PlayerId userId, @Nullable java.lang.String metadata)
Sends a request to get thread control.
@Nullable public SendResponse takeThreadControl(@NotNull ai.tock.bot.engine.user.PlayerId userId, @Nullable java.lang.String metadata)
Takes the thread control.
@Nullable public SendResponse passThreadControl(@NotNull ai.tock.bot.engine.user.PlayerId userId, @NotNull java.lang.String targetAppId, @Nullable java.lang.String metadata)
Passes thread control.
public void send(@NotNull
ai.tock.bot.engine.event.Event event,
@NotNull
ai.tock.bot.connector.ConnectorCallback callback,
long delayInMs)
Send the event to messenger asynchronously. Contains checks to ensure that two Action for the same recipient are sent sequentially.
@NotNull
public ai.tock.bot.engine.user.UserPreferences loadProfile(@NotNull
ai.tock.bot.connector.ConnectorCallback callback,
@NotNull
ai.tock.bot.engine.user.PlayerId userId)
@Nullable
public ai.tock.bot.engine.user.UserPreferences refreshProfile(@NotNull
ai.tock.bot.connector.ConnectorCallback callback,
@NotNull
ai.tock.bot.engine.user.PlayerId userId)
public void notify(@NotNull
ai.tock.bot.engine.ConnectorController controller,
@NotNull
ai.tock.bot.engine.user.PlayerId recipientId,
@NotNull
ai.tock.bot.definition.IntentAware intent,
@Nullable
ai.tock.bot.definition.StoryStep<? extends ai.tock.bot.definition.StoryHandlerDefinition> step,
@NotNull
java.util.Map<java.lang.String,java.lang.String> parameters,
@Nullable
ai.tock.bot.engine.action.ActionNotificationType notificationType,
@NotNull
kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> errorListener)
@NotNull
public kotlin.jvm.functions.Function1<ai.tock.bot.engine.BotBus,ai.tock.bot.connector.ConnectorMessage> addSuggestions(@NotNull
java.lang.CharSequence text,
@NotNull
java.util.List<? extends java.lang.CharSequence> suggestions)
@NotNull
public kotlin.jvm.functions.Function1<ai.tock.bot.engine.BotBus,ai.tock.bot.connector.ConnectorMessage> addSuggestions(@NotNull
ai.tock.bot.connector.ConnectorMessage message,
@NotNull
java.util.List<? extends java.lang.CharSequence> suggestions)
@NotNull
public kotlin.jvm.functions.Function1<ai.tock.bot.engine.BotBus,java.util.List> toConnectorMessage(@NotNull
ai.tock.bot.connector.media.MediaMessage message)