tock / ai.tock.bot.api.client / ClientBus

ClientBus

interface ClientBus : Bus<ClientBus> (source)

Bus implementation for Tock Bot APÏ mode.

Properties

botDefinition

The bot definition.

abstract val botDefinition: ClientBotDefinition

entities

The entity list.

abstract val entities: MutableList<Entity>

message

The user message.

abstract val message: UserMessage

step

The current step.

abstract var step: ClientStep?

story

The current story.

abstract var story: ClientStoryDefinition

Functions

end

Sends a Card as last bot answer.

abstract fun end(card: Card): ClientBus

Sends a [Carousel as last bot answer.

abstract fun end(carousel: Carousel): ClientBus

Sends a text with suggestions as last bot answer.

abstract fun end(i18nText: CharSequence, suggestions: List<Suggestion>, delay: Long = defaultDelay(currentAnswerIndex), vararg i18nArgs: Any?): ClientBus
open fun end(i18nText: CharSequence, suggestions: List<CharSequence>): ClientBus

entity

Finds the Entity from the specified entity role.

open fun entity(role: String): Entity?

entityText

Returns the Entity text content from the specified entity role.

open fun entityText(role: String): String?

entityValue

Returns the corresponding Entity from the specified entity role.

open fun <T : Value> entityValue(role: String): T?

handle

Handles the current request.

abstract fun handle(): Unit

newAction

Creates a new Action.

open fun newAction(title: CharSequence, url: String? = null): Action

newAttachment

Creates a new Attachment.

open fun newAttachment(url: String, type: AttachmentType? = null): Attachment

newCard

Creates a new Card.

open fun newCard(title: CharSequence? = null, subTitle: CharSequence? = null, attachment: Attachment? = null, actions: List<Action> = emptyList(), delay: Long = defaultDelay(currentAnswerIndex)): Card
open fun newCard(title: CharSequence? = null, subTitle: CharSequence? = null, attachment: Attachment? = null, vararg actions: Action, delay: Long = defaultDelay(currentAnswerIndex)): Card

newCarousel

Creates a new Carousel.

open fun newCarousel(cards: List<Card>, delay: Long = defaultDelay(currentAnswerIndex)): Carousel
open fun newCarousel(vararg cards: Card, delay: Long = defaultDelay(currentAnswerIndex)): Carousel

removeEntity

Removes the entity of the specified role.

open fun removeEntity(role: String): Boolean

Remove the specified entity.

open fun removeEntity(entity: Entity): Boolean

send

Sends a Card.

abstract fun send(card: Card): ClientBus

Sends a Carousel.

abstract fun send(carousel: Carousel): ClientBus

Sends a text with suggestions.

abstract fun send(i18nText: CharSequence, suggestions: List<Suggestion>, delay: Long = defaultDelay(currentAnswerIndex), vararg i18nArgs: Any?): ClientBus
open fun send(i18nText: CharSequence, suggestions: List<CharSequence>): ClientBus

translate

Translates and format if needed the text with the optionals args.

open fun translate(text: CharSequence?, vararg args: Any?): I18nText

Extension Functions

alexaReprompt

Set a reprompt.

fun I18nTranslator.alexaReprompt(reprompt: CharSequence): AlexaMessage

alexaStandardCard

Add the specified card.

fun I18nTranslator.alexaStandardCard(title: CharSequence, text: CharSequence, smallImageUrl: String, largeImageUrl: String = smallImageUrl): AlexaMessage

attachmentField

fun I18nTranslator.attachmentField(title: String, value: String, short: Boolean = true): AttachmentField

basicCard

Provides a GABasicCard with all available parameters.

fun I18nTranslator.basicCard(title: CharSequence?, subtitle: CharSequence?, formattedText: CharSequence?, image: GAImage?, buttons: List<GAButton>): GABasicCard

Provides a GABasicCard with only one GAButton (only one is supported for now anyway).

fun I18nTranslator.basicCard(title: CharSequence? = null, subtitle: CharSequence? = null, formattedText: CharSequence? = null, image: GAImage? = null, button: GAButton? = null): GABasicCard

Provides a GABasicCard without formattedText.

fun I18nTranslator.basicCard(title: CharSequence, subtitle: CharSequence, image: GAImage, button: GAButton): GABasicCard

Provides a GABasicCard with title and button.

fun I18nTranslator.basicCard(title: CharSequence, button: GAButton): GABasicCard

Provides a GABasicCard with title and subtitle.

fun I18nTranslator.basicCard(title: CharSequence, subtitle: CharSequence): GABasicCard

Provides a GABasicCard with title and image.

fun I18nTranslator.basicCard(title: CharSequence, image: GAImage): GABasicCard

Provides a GABasicCard with title, subtitle and image.

fun I18nTranslator.basicCard(title: CharSequence, subtitle: CharSequence, image: GAImage): GABasicCard

Provides a GABasicCard with an image.

fun I18nTranslator.basicCard(image: GAImage): GABasicCard

buttonsTemplate

Creates a button template https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template

fun I18nTranslator.buttonsTemplate(text: CharSequence, vararg actions: UserAction): AttachmentMessage
fun I18nTranslator.buttonsTemplate(text: CharSequence, actions: List<UserAction>): AttachmentMessage

callToButton

fun I18nTranslator.callToButton(title: CharSequence, phoneNumber: String): CallButton

expectedIntentForCarousel

Provides a GAExpectedIntent with a GACarouselSelect.

fun I18nTranslator.expectedIntentForCarousel(items: List<GACarouselItem>): GAExpectedIntent

expectedIntentForList

Provides a GAExpectedIntent with a GAListSelect.

fun I18nTranslator.expectedIntentForList(items: List<GAListItem>, title: CharSequence? = null): GAExpectedIntent

expectedIntentForSimpleSelect

Provides a GAExpectedIntent with a GASimpleSelect.

fun I18nTranslator.expectedIntentForSimpleSelect(items: List<GASelectItem>): GAExpectedIntent

flexibleSimpleResponse

Provides a GASimpleResponse with specified textToSpeech, ssml and displayText.

fun I18nTranslator.flexibleSimpleResponse(textToSpeech: CharSequence? = null, ssml: CharSequence? = null, displayText: CharSequence? = null): GASimpleResponse

gaButton

Provides a GAButton.

fun I18nTranslator.gaButton(title: CharSequence, url: String): GAButton

gaFinalMessage

Final Google Assistant message (end of conversation).

fun I18nTranslator.gaFinalMessage(richResponse: GARichResponse): GAResponseConnectorMessage
fun I18nTranslator.gaFinalMessage(text: CharSequence? = null): GAResponseConnectorMessage

gaFlexibleMessageForCarousel

Add a basic card if only one element in the items list, in order to avoid the limitation of 2 items.

fun I18nTranslator.gaFlexibleMessageForCarousel(items: List<GACarouselItem>, suggestions: List<CharSequence> = emptyList(), oneItemTitle: CharSequence? = null, oneItemSubtitle: CharSequence? = null, oneItemDescription: CharSequence? = null, oneItemSuggestions: List<CharSequence> = emptyList()): GAResponseConnectorMessage
fun I18nTranslator.gaFlexibleMessageForCarousel(items: List<GACarouselItem>, suggestions: List<CharSequence> = emptyList(), oneItemSuggestions: List<CharSequence> = emptyList(), oneItemBasicCardProvider: (GACarouselItem) -> GABasicCard = { basicCard( it.title.raw, if (it.image != null) it.description?.raw else null, if (it.image == null) it.description?.raw else null, it.image ) }): GAResponseConnectorMessage

gaFlexibleMessageForList

Add a basic card if only one element in the items list in order to avoid the limitation of 2 items.

fun I18nTranslator.gaFlexibleMessageForList(items: List<GAListItem>, title: CharSequence? = null, suggestions: List<CharSequence> = emptyList(), oneItemTitle: CharSequence? = null, oneItemSubtitle: CharSequence? = null, oneItemDescription: CharSequence? = null, oneItemSuggestions: List<CharSequence> = emptyList()): GAResponseConnectorMessage

gaImage

Provides a GAImage with all available parameters.

fun I18nTranslator.gaImage(url: String, accessibilityText: CharSequence, height: Int? = null, width: Int? = null): GAImage

gaMessage

Google Assistant Message with all available parameters.

fun I18nTranslator.gaMessage(inputPrompt: GAInputPrompt, possibleIntents: List<GAExpectedIntent> = listOf( expectedTextIntent() ), speechBiasingHints: List<String> = emptyList()): GAResponseConnectorMessage

Google Assistant Message with suggestions.

fun I18nTranslator.gaMessage(text: CharSequence, vararg suggestions: CharSequence): GAResponseConnectorMessage

Google Assistant Message with GABasicCard.

fun I18nTranslator.gaMessage(text: CharSequence, basicCard: GABasicCard): GAResponseConnectorMessage

Google Assistant Message with GARichResponse.

fun I18nTranslator.gaMessage(richResponse: GARichResponse): GAResponseConnectorMessage

Google Assistant Message with one GAExpectedIntent.

fun I18nTranslator.gaMessage(possibleIntent: GAExpectedIntent): GAResponseConnectorMessage

Google Assistant Message with multiple GAExpectedIntent.

fun I18nTranslator.gaMessage(possibleIntents: List<GAExpectedIntent>): GAResponseConnectorMessage

Google Assistant Message with text and multiple GAExpectedIntent.

fun I18nTranslator.gaMessage(text: CharSequence, possibleIntents: List<GAExpectedIntent>): GAResponseConnectorMessage

Provides a message with a GAListSelect.

fun I18nTranslator.gaMessage(gaRichResponse: GARichResponse, listItems: List<GAListItem>, title: CharSequence? = null): GAResponseConnectorMessage

gaMessageForCarousel

Provides a message with a GACarouselSelect.

fun I18nTranslator.gaMessageForCarousel(items: List<GACarouselItem>, suggestions: List<CharSequence> = emptyList()): GAResponseConnectorMessage

gaMessageForList

Provides a message with a GAListSelect and a list of GASuggestion.

fun I18nTranslator.gaMessageForList(items: List<GAListItem>, title: CharSequence? = null, suggestions: List<CharSequence> = emptyList()): GAResponseConnectorMessage

gaTransactionOrderDecision

Build an GATransactionDecisionValueSpecV3 message.

fun I18nTranslator.gaTransactionOrderDecision(order: GAOrder, orderOptions: GAOrderOptionsV3? = null, paymentParameters: GAPaymentParameters? = null, presentationOptions: GAPresentationOptions? = null): GAResponseConnectorMessage

gaTransactionOrderUpdate

Build an GAStructuredResponse from an GAOrderUpdateV3.

fun I18nTranslator.gaTransactionOrderUpdate(orderUpdate: GAOrderUpdateV3): GAResponseConnectorMessage

gaTransactionRequirementsCheckV3

Build a GATransactionRequirementsCheckSpecV3 response.

fun I18nTranslator.gaTransactionRequirementsCheckV3(): GAResponseConnectorMessage

genericElement

Creates a generic element.

fun I18nTranslator.genericElement(title: CharSequence, subtitle: CharSequence? = null, imageUrl: String? = null, buttons: List<Button>? = null): Element

inputPrompt

Provides a GAInputPrompt with all available parameters.

fun I18nTranslator.inputPrompt(richResponse: GARichResponse, noInputPrompts: List<GASimpleResponse> = emptyList()): GAInputPrompt

Provides a GAInputPrompt with a simple GARichResponse builder.

fun I18nTranslator.inputPrompt(text: CharSequence, linkOutSuggestion: GALinkOutSuggestion? = null, noInputPrompts: List<GASimpleResponse> = emptyList()): GAInputPrompt

item

Provides a GAItem with all available parameters.

fun I18nTranslator.item(simpleResponse: GASimpleResponse? = null, basicCard: GABasicCard? = null, structuredResponse: GAStructuredResponse? = null): GAItem

Provides a GAItem with a GABasicCard.

fun I18nTranslator.item(basicCard: GABasicCard): GAItem

Provides a GAItem with a GAStructuredResponse.

fun I18nTranslator.item(structuredResponse: GAStructuredResponse): GAItem

Provides a GAItem with a GASimpleResponse.

fun I18nTranslator.item(simpleResponse: GASimpleResponse): GAItem

linkOutSuggestion

Provides a GALinkOutSuggestion.

fun I18nTranslator.linkOutSuggestion(destinationName: CharSequence, url: String): GALinkOutSuggestion

multiLineMessage

fun I18nTranslator.multiLineMessage(lines: List<CharSequence>, channel: String? = null): SlackMessageOut

nlpOption

Creates a NLP Option Quick Reply without description

fun I18nTranslator.nlpOption(label: CharSequence): OptionWithoutDescription
fun I18nTranslator.nlpOption(label: CharSequence, description: CharSequence): Option

nlpPostbackButton

This button does not use any custom payload, but the textToSend will we parsed by the NLP engine.

fun I18nTranslator.nlpPostbackButton(title: CharSequence, textToSend: CharSequence = title): PostbackButton

nlpQuickReply

This quick reply does not use any custom payload, but the textToSend will we parsed by the NLP engine.

fun I18nTranslator.nlpQuickReply(title: CharSequence, textToSend: CharSequence = title, imageUrl: String? = null): QuickReply

optionValueSpec

Provides a GAOptionValueSpec with all available parameters.

fun I18nTranslator.optionValueSpec(simpleSelect: GASimpleSelect? = null, listSelect: GAListSelect? = null, carouselSelect: GACarouselSelect? = null): GAOptionValueSpec

permissionIntent

Google Assistant Message asking for GAPermission.

fun I18nTranslator.permissionIntent(optionalContext: CharSequence? = null, vararg permissions: GAPermission): GAExpectedIntent

richResponse

Provides a GARichResponse with suggestions as String.

fun I18nTranslator.richResponse(items: List<GAItem>, linkOutSuggestion: GALinkOutSuggestion? = null, vararg suggestions: CharSequence): GARichResponse

Provides a GARichResponse without linkOutSuggestion.

fun I18nTranslator.richResponse(items: List<GAItem>, vararg suggestions: CharSequence): GARichResponse
fun I18nTranslator.richResponse(items: List<GAItem>, suggestions: List<CharSequence>): GARichResponse

Provides a GARichResponse with only one GAItem.

fun I18nTranslator.richResponse(item: GAItem, linkOutSuggestion: GALinkOutSuggestion? = null, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(item: GAItem, linkOutSuggestion: GALinkOutSuggestion? = null, vararg suggestions: CharSequence): GARichResponse

Provides a GARichResponse with text item.

fun I18nTranslator.richResponse(text: CharSequence, linkOutSuggestion: GALinkOutSuggestion? = null, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(text: CharSequence, linkOutSuggestion: GALinkOutSuggestion? = null, vararg suggestions: CharSequence): GARichResponse
fun I18nTranslator.richResponse(text: CharSequence, vararg suggestions: CharSequence): GARichResponse
fun I18nTranslator.richResponse(text: CharSequence, suggestions: List<CharSequence>): GARichResponse

Provides a GARichResponse with a text and a GABasicCard.

fun I18nTranslator.richResponse(text: CharSequence, basicCard: GABasicCard, linkOutSuggestion: GALinkOutSuggestion? = null, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(text: CharSequence, basicCard: GABasicCard, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(text: CharSequence, basicCard: GABasicCard, vararg suggestions: CharSequence): GARichResponse

Provides a GARichResponse with a GABasicCard.

fun I18nTranslator.richResponse(basicCard: GABasicCard, linkOutSuggestion: GALinkOutSuggestion? = null, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(basicCard: GABasicCard, suggestions: List<CharSequence>): GARichResponse
fun I18nTranslator.richResponse(basicCard: GABasicCard, vararg suggestions: CharSequence): GARichResponse

simpleResponse

Provides a GASimpleResponse with specified CharSequence.

fun I18nTranslator.simpleResponse(text: CharSequence): GASimpleResponse

slackAttachment

fun I18nTranslator.slackAttachment(text: CharSequence? = null, vararg buttons: Button): SlackMessageAttachment
fun I18nTranslator.slackAttachment(vararg buttons: Button): SlackMessageAttachment
fun I18nTranslator.slackAttachment(text: CharSequence? = null, buttons: List<Button> = emptyList(), color: String = "good", pretext: String? = null, fallback: String = translate(text).toString(), vararg fields: AttachmentField): SlackMessageAttachment

slackMessage

fun I18nTranslator.slackMessage(message: CharSequence, vararg attachments: SlackMessageAttachment): SlackMessageOut
fun I18nTranslator.slackMessage(message: CharSequence, channel: String? = null, vararg attachments: SlackMessageAttachment): SlackMessageOut

standaloneQuickReply

Creates a quick reply from an I18nTranslator.

fun I18nTranslator.standaloneQuickReply(title: CharSequence, targetIntent: IntentAware, parameters: Parameters = Parameters(), step: StoryStep<out StoryHandlerDefinition>? = null, imageUrl: String? = null, busStep: StoryStep<out StoryHandlerDefinition>? = null, currentIntent: Intent? = null, sourceAppId: String?): QuickReply

suggestion

Provides a GASuggestion.

fun I18nTranslator.suggestion(text: CharSequence): GASuggestion

teamsCarousel

fun I18nTranslator.teamsCarousel(carouselContent: List<TeamsBotMessage>): TeamsCarousel

teamsHeroCard

fun I18nTranslator.teamsHeroCard(title: CharSequence? = null, subtitle: CharSequence? = null, attachmentContent: CharSequence, images: List<CardImage>? = null, buttons: List<CardAction>? = null, tap: CardAction? = null): TeamsHeroCard

teamsMessage

fun I18nTranslator.teamsMessage(text: CharSequence): TeamsBotTextMessage

teamsMessageWithButtonCard

fun I18nTranslator.teamsMessageWithButtonCard(urlText: CharSequence, links: List<CardAction>): TeamsCardAction

text

Creates a text with quick replies.

fun I18nTranslator.text(text: CharSequence, vararg quickReplies: QuickReply): TextMessage
fun I18nTranslator.text(text: CharSequence, quickReplies: List<QuickReply>): TextMessage

textMessage

fun I18nTranslator.textMessage(message: CharSequence): SlackMessageOut

updatePermissionIntent

Google Assistant Message asking for update GAPermission.

fun I18nTranslator.updatePermissionIntent(intent: String): GAExpectedIntent

urlButton

Creates an url button.

fun I18nTranslator.urlButton(title: CharSequence, url: String): UrlButton

webMessage

Creates a text with buttons.

fun I18nTranslator.webMessage(title: CharSequence, vararg buttons: WebButton): OldWebMessage
fun I18nTranslator.webMessage(title: CharSequence, buttons: List<WebButton>): OldWebMessage
fun I18nTranslator.webMessage(title: CharSequence, vararg buttons: Button): WebMessage

Creates a text with a list of buttons.

fun I18nTranslator.webMessage(title: CharSequence, buttons: List<Button> = emptyList()): WebMessage

Inheritors

TockClientBus

class TockClientBus : ClientBus