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.

Libraries

ai_chatbot_wrapper