This library provides an SDK to easily integrate an AI Chatbot into your native Android applications.
- Bi-directional Communication:
- Your Android app can send commands to the chatbot using
DialpadChatbotCommand
. - The chatbot can send events to your Android app using
DialpadChatbotEvent
.
- Your Android app can send commands to the chatbot using
- Compose Support: The SDK includes a
DialpadChatbotView
Composable function for easy integration with Jetpack Compose. - WebView-based Implementation: Leverages WebView for rendering the chatbot interface.
Visit this page for more information.
Use the DialpadChatbotView
Composable to display the chatbot within your app.
@Composable
fun MyChatbotScreen() {
val commands = remember { MutableSharedFlow<DialpadChatbotCommand>() }
DialpadChatbotView(
url = "YOUR_CHATBOT_URL", // Replace with your chatbot URL
modifier = Modifier.fillMaxSize(),
commands = commands,
onEvent = { event ->
when (event) {
DialpadChatbotEvent.SessionStarted -> {
// Handle session started event
}
DialpadChatbotEvent.SessionEnded -> {
// Handle session ended event
}
}
}
)
}
url
: The URL of the Chatbot to be loaded in the WebView.modifier
: Modifier for the layout of the WebView.commands
: A SharedFlow ofDialpadChatbotCommand
to send commands to the Chatbot.onEvent
: A callback function to receiveDialpadChatbotEvent
from the Chatbot.
Use the commands
SharedFlow
to send commands to the chatbot. For example, to end a session:
scope.launch {
commands.emit(DialpadChatbotCommand.EndSession)
}
DialpadChatbotEvent.SessionStarted
- indicates that a chatbot session has started.DialpadChatbotEvent.SessionEnded
- indicates that a chatbot session has ended.
DialpadChatbotCommand.EndSession
- command to end the current chatbot session.