iserve_chatbot 0.1.0
iserve_chatbot: ^0.1.0 copied to clipboard
A reusable Flutter chatbot package with API integration, session management, interactive options, and customizable UI.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:iserve_chatbot/iserve_chatbot.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
/// base credentials for api
final chatApiCredentials = const ChatbotApiCredentials(
///base url for api
baseUrl: 'https://example.com/api',
/// endpoint to send messages
messageEndpoint: 'messageEndpoint',
///endpoint to send option selection
optionEndpoint: 'optionEndpoint',
/// endpoint to get current session
sessionEndpoint: 'sessionEndpoint',
///endpoint to get history of previous chats
threadsEndpoint: 'threadsEndpoint',
);
/// Current user (or static)
final user = const ChatbotUser(
orgId: 'example-org',
userId: 'example-user',
contactId: 'example-contact',
email: 'example@example.com',
orgCode: 'example',
);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'iServe Chatbot Example',
home: Scaffold(
body: iServeChatbot(
user: user,
chatApiCredentials: chatApiCredentials,
showChatHistoryMenu: true,
),
),
);
}
}