Skip to content

Commit

Permalink
Addition of QR for configured stories whasappCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
BENKACI Amira authored and vsct-jburet committed Dec 18, 2024
1 parent 7a71c9c commit c4d5d0c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ package ai.tock.bot.connector.whatsapp.cloud
import ai.tock.bot.connector.ConnectorBase
import ai.tock.bot.connector.ConnectorCallback
import ai.tock.bot.connector.ConnectorData
import ai.tock.bot.connector.ConnectorMessage
import ai.tock.bot.connector.whatsapp.cloud.model.send.manageTemplate.WhatsAppCloudTemplate
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.WhatsAppCloudBotMessage
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.content.WhatsAppCloudBotActionButton
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.content.WhatsAppCloudBotActionButtonReply
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.content.WhatsAppCloudBotInteractive
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.content.WhatsAppCloudBotInteractiveMessage
import ai.tock.bot.connector.whatsapp.cloud.model.webhook.Change
import ai.tock.bot.connector.whatsapp.cloud.model.webhook.Entry
import ai.tock.bot.connector.whatsapp.cloud.model.webhook.WebHookEventReceiveMessage
Expand All @@ -29,6 +35,7 @@ import ai.tock.bot.connector.whatsapp.cloud.services.WhatsAppCloudApiService
import ai.tock.bot.definition.IntentAware
import ai.tock.bot.definition.StoryHandlerDefinition
import ai.tock.bot.definition.StoryStep
import ai.tock.bot.engine.BotBus
import ai.tock.bot.engine.BotRepository
import ai.tock.bot.engine.ConnectorController
import ai.tock.bot.engine.action.Action
Expand Down Expand Up @@ -213,4 +220,7 @@ class WhatsAppConnectorCloudConnector internal constructor(
)
)
}

override fun addSuggestions(text: CharSequence, suggestions: List<CharSequence>): BotBus.() -> ConnectorMessage? =
{ whatsAppCloudReplyButtonMessage(text.toString(), suggestions.map { whatsAppCloudNlpQuickReply(it) }) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import ai.tock.bot.connector.whatsapp.cloud.UserHashedIdCache
import ai.tock.bot.connector.whatsapp.cloud.WhatsAppCloudConnectorMessage
import ai.tock.bot.connector.whatsapp.cloud.model.send.message.content.*
import ai.tock.bot.connector.whatsapp.cloud.whatsAppCloudConnectorType
import ai.tock.bot.definition.Intent
import ai.tock.bot.engine.action.SendChoice
import ai.tock.bot.engine.action.SendChoice.Companion.TITLE_PARAMETER
import ai.tock.bot.engine.message.Choice
import ai.tock.bot.engine.message.GenericMessage
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonSubTypes
Expand Down Expand Up @@ -57,4 +62,38 @@ abstract class WhatsAppCloudBotMessage (val type: WhatsAppCloudBotMessageType, @

@get:JsonIgnore
val to: String get() = userId?.let { UserHashedIdCache.getRealId(it) } ?: "unknown"



override fun toGenericMessage(): GenericMessage? {

return when(this) {
is WhatsAppCloudBotInteractiveMessage -> GenericMessage(
connectorType = whatsAppCloudConnectorType,
choices = interactive.action?.buttons?.mapNotNull { actionButton ->
actionButton.reply.let {

SendChoice.decodeChoiceId(it.id)
.let { (intent, params) ->
Choice(
intent,
params + (TITLE_PARAMETER to it.title)
)
}


}
}!!


)

else -> GenericMessage(
connectorType = whatsAppCloudConnectorType,
texts = mapOf(GenericMessage.TEXT_PARAM to "Unsupported message type")
)
}
}


}

0 comments on commit c4d5d0c

Please sign in to comment.