kindly_sdk 1.0.1
kindly_sdk: ^1.0.1 copied to clipboard
Kindly Chat SDK for Flutter - Customer support chat widget for iOS and Android applications.
Kindly Chat SDK for Flutter #
Kindly Chat SDK for Flutter - Customer support chat widget for iOS and Android applications.
Features #
- 🎨 Customizable themes and colors
- 🔐 Authentication support with JWT tokens
- 🌍 Multi-language support
- 💬 Real-time chat with your customers
- 📱 Native iOS and Android implementations
- 🔔 Push notification support
- 🎯 Trigger specific dialogues
- 📊 Context data support
Requirements #
- Flutter >=2.0.0
- iOS >=12.0
- Android API Level >=21
Installation #
Add kindly_sdk to your pubspec.yaml:
dependencies:
kindly_sdk: ^1.0.0
Run flutter pub get to install the package.
iOS Setup #
No additional setup required. The SDK will be automatically linked.
Android Setup #
No additional setup required. The SDK will be automatically linked.
Usage #
Basic Setup #
import 'package:kindly_sdk/kindly.dart';
// Initialize the SDK
await KindlySDK.start(
botKey: 'YOUR_BOT_KEY',
);
// Display the chat
await KindlySDK.displayChat();
Authentication #
If your chat requires authentication, provide an auth token callback:
await KindlySDK.start(
botKey: 'YOUR_BOT_KEY',
authTokenCallback: () async {
// Fetch your JWT token from your backend
final token = await yourAuthService.getToken();
return token;
},
);
Custom Theme #
Customize the chat appearance to match your brand:
await KindlySDK.setCustomTheme(
background: Colors.white,
botMessageBackground: Colors.grey[200],
botMessageText: Colors.black,
userMessageBackground: Colors.blue,
userMessageText: Colors.white,
buttonBackground: Colors.blue,
buttonText: Colors.white,
navBarBackground: Colors.blue,
navBarText: Colors.white,
inputBackground: Colors.grey[100],
inputText: Colors.black,
);
Context Data #
Send contextual information about the user or session:
await KindlySDK.setNewContext({
'userId': '12345',
'userName': 'John Doe',
'email': '[email protected]',
'plan': 'premium',
});
// Clear context when needed
await KindlySDK.clearNewContext();
Trigger Specific Dialogues #
Start a conversation with a specific dialogue:
// Launch chat with a specific dialogue
await KindlySDK.launchChat(
triggerDialogueId: 'welcome_dialogue',
);
// Or trigger a dialogue in an active chat
await KindlySDK.triggerDialogue('help_dialogue');
Push Notifications #
iOS
// Set APNS device token
await KindlySDK.setAPNSDeviceToken(deviceToken);
// Handle notification
await KindlySDK.handleNotification(notificationData);
// Check if notification is from Kindly
bool isKindly = await KindlySDK.isKindlyNotification(notificationData);
Android
// Save FCM token
await KindlySDK.saveNotificationToken(fcmToken);
// Handle notification
await KindlySDK.handleNotification(remoteMessageData);
// Check if notification is from Kindly
bool isKindly = await KindlySDK.isKindlyNotification(remoteMessageData);
Other Features #
// Check if chat is displayed
bool isDisplayed = await KindlySDK.isChatDisplayed;
// Enable verbose logging
await KindlySDK.setVerboseLogging(true);
// Enable crash reporting
await KindlySDK.setCrashReporting(true);
// Close chat
await KindlySDK.closeChat();
// End chat session completely
await KindlySDK.endChat();
API Reference #
KindlySDK.start() #
Initializes the SDK with your bot configuration.
Parameters:
botKey(required): Your Kindly bot keylanguageCode(optional): Initial language code (e.g., 'en', 'no')authTokenCallback(optional): Callback to provide JWT authentication token
KindlySDK.displayChat() #
Shows the chat interface.
Parameters:
languageCode(optional): Override the default languagetriggerDialogueId(optional): Start with a specific dialogue
KindlySDK.setCustomTheme() #
Customizes the chat appearance.
Parameters: All parameters are optional Color values:
background: Main background colorbotMessageBackground: Bot message bubble backgroundbotMessageText: Bot message text coloruserMessageBackground: User message bubble backgrounduserMessageText: User message text colorbuttonBackground: Button background colorbuttonText: Button text colornavBarBackground: Navigation bar backgroundnavBarText: Navigation bar text colorinputBackground: Input field backgroundinputText: Input field text color- And more...
KindlySDK.setNewContext() #
Sets contextual data for the chat session.
Parameters:
context: Map<String, String> of key-value pairs
KindlySDK.triggerDialogue() #
Triggers a specific dialogue in the chat.
Parameters:
dialogueId: The ID of the dialogue to trigger
License #
This project is licensed under the MIT License - see the LICENSE file for details.