ai_chatbot_wrapper
A lightweight Flutter wrapper for integrating AI-powered chatbot functionality into your apps. Supports both real OpenAI GPT interactions and a mock service for local development.
โจ Features
- Plug-and-play chatbot UI (
ChatBotView
) - Real OpenAI API integration via
OpenAIService
- Mock AI service for local development and testing
- Fully customizable message styling and loading indicators
๐ Installation
1. Add the dependency
Using Git (for remote repositories)
dependencies:
ai_chatbot_wrapper:
git:
url: https://github.com/DeepakKishore-S/ai_chatbot_wrapper # Replace with your GitHub URL
Using Local Path (for local development/testing)
dependencies:
ai_chatbot_wrapper:
path: ../path_to_your_package # Replace with your local path
Then run:
flutter pub get
๐ Configuration
2. Configure OpenAI API Key (Optional)
If using the OpenAI API:
final service = OpenAIService(apiKey: "your-api-key");
Get your API key from OpenAI API Platform.
If you're testing locally, use the mock service:
final service = MockAIService();
๐งฉ Example Usage
3. Integrate the Chatbot View
import 'package:flutter/material.dart';
import 'package:ai_chatbot_wrapper/ai_chatbot_wrapper.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("AI Chatbot Example")),
body: ChatBotView(
sendMessage: OpenAIService(apiKey: "your-api-key").sendMessage,
),
),
);
}
}
๐งช Local Testing with Mock Service
Use the MockAIService
for testing without API calls:
ChatBotView(
sendMessage: MockAIService().sendMessage,
)
๐ผ๏ธ Example Screenshots (Add if available)
- Real Chatbot (OpenAI GPT)
- Mock Chatbot (Local Testing)
๐งฉ Troubleshooting
- "Failed to connect to OpenAI API": Check your API key and internet connection.
- "Error: Insufficient quota": Log in to OpenAI and check your usage.
๐ License
MIT License. See the LICENSE file for details.
๐ค Contributing
We welcome contributions! Please submit a pull request or open an issue. See CONTRIBUTING.md for guidelines.
๐ฌ Contact
For questions or suggestions, open an issue or reach out at deepakkishore.sc@gmail.com.
Let me know if you'd like a badge section, example screenshots section with mockups, or support for publishing to pub.dev
.