Complete sample implementation demonstrating Kore.ai chatbot integration with selective feature loading
This sample app showcases how to integrate the Kore Bot SDK with selective dependency installation, allowing you to choose only the features you need and save significant bundle size.
- β¨ Features
- π Quick Start
- π¦ Installation
- π― Basic Usage
- π¨ Customization
- π API Reference
- π οΈ Advanced Configuration
- π Permissions Setup
- π± Examples
- π€ Contributing
- π License
- π¬ Support
|
|
Get up and running in minutes:
import React from 'react';
import { View } from 'react-native';
import KoreChat, { BotConfigModel } from 'rn-kore-bot-sdk-v77';
const App = () => {
const botConfig: BotConfigModel = {
botId: 'your-bot-id',
chatBotName: 'Assistant',
serverUrl: 'https://your.server.url',
brandingAPIUrl: 'https://your.branding.url',
};
return (
<View style={{ flex: 1 }}>
<KoreChat
botConfig={botConfig}
onListItemClick={(item) => console.log('π Item clicked:', item)}
onHeaderActionsClick={(action) => console.log('β‘ Action:', action)}
/>
</View>
);
};
export default App;git clone <repository-url>
cd SampleApp
npm installThis sample app demonstrates 3 different installation approaches:
Perfect for basic chat functionality
# Only install required dependencies
npm install \
"@react-native-async-storage/async-storage@^2.2.0" \
"@react-native-community/netinfo@^11.4.1" \
"@react-navigation/native@^7.1.14" \
"@react-navigation/stack@^7.4.2" \
"react-native-gesture-handler@^2.27.2" \
"react-native-safe-area-context@^5.4.1" \
"react-native-screens@^4.13.1"Features Available:
- β Basic chat interface
- β Text messaging
- β Simple templates
- β Voice features (buttons hidden)
- β Audio playback (silent mode)
- β Video content (static thumbnails)
Adds voice recognition and TTS
# Install minimal + voice features
npm install \
"@react-native-voice/voice@^3.2.4" \
"react-native-tts@^4.1.1" \
"react-native-permissions@^5.4.1"Additional Features:
- β Voice-to-text input
- β Text-to-speech playback
- β Microphone permissions handling
Install all optional dependencies
# Complete feature set
npm install \
"@react-native-picker/picker@^2.11.0" \
"@react-native-voice/voice@^3.2.4" \
"@react-native-community/datetimepicker@^8.4.4" \
"react-native-communications@^2.2.1" \
"react-native-document-picker@^9.3.1" \
"react-native-fast-image@^8.6.3" \
"react-native-image-picker@^8.2.1" \
"react-native-parsed-text@^0.0.22" \
"react-native-popover-view@^6.1.0" \
"react-native-reanimated-carousel@^4.0.3" \
"react-native-sound@^0.12.0" \
"react-native-tts@^4.1.1" \
"react-native-video@^6.16.1"All Features:
- β Everything from Options A & B
- β Rich media support (images, videos, audio)
- β Advanced templates (carousels, pickers)
- β File attachments
- β Enhanced UI components
| Feature | Minimal | Voice | Full |
|---|---|---|---|
| Bundle Size | Base | Base + 80KB | Base + 380KB |
| Savings | 380KB | 300KB | 0KB |
| Chat Interface | β | β | β |
| Voice Input | β | β | β |
| Audio Playback | β | β | β |
| Video Messages | π· Thumbnail | π· Thumbnail | |
| File Uploads | β | β | β |
| Rich Templates | Basic | Basic | Advanced |
| Phone/Email Actions | Basic | Basic | Native |
π iOS Setup
cd ios && pod install && cd ..Add to ios/YourProject/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access for voice messages</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>This app uses speech recognition for voice-to-text</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs photo library access for attachments</string>
<key>NSCameraUsageDescription</key>
<string>This app needs camera access for photos</string>π€ Android Setup
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />import React from 'react';
import { SafeAreaView, StatusBar } from 'react-native';
import KoreChat, { BotConfigModel, ThemeProvider } from 'rn-kore-bot-sdk-v77';
const App = () => {
const botConfig: BotConfigModel = {
botId: 'st-12345678-1234-1234-1234-123456789012',
chatBotName: 'My Assistant',
serverUrl: 'https://bots.kore.ai',
brandingAPIUrl: 'https://bots.kore.ai',
customerId: 'your-customer-id',
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
identity: 'your-user-identity',
isAnonymous: false,
isPlatform: true,
};
return (
<SafeAreaView style={{ flex: 1, backgroundColor: '#f5f5f5' }}>
<StatusBar barStyle="dark-content" backgroundColor="#ffffff" />
<KoreChat
botConfig={botConfig}
onListItemClick={handleListItemClick}
onHeaderActionsClick={handleHeaderAction}
/>
</SafeAreaView>
);
};
const handleListItemClick = (item: any) => {
console.log('π List item selected:', item);
};
const handleHeaderAction = (action: any) => {
console.log('β‘ Header action triggered:', action);
};
export default App;import { ThemeProvider } from 'rn-kore-bot-sdk-v77';
const customTheme = {
primaryColor: '#007AFF',
secondaryColor: '#5856D6',
backgroundColor: '#F2F2F7',
textColor: '#000000',
borderColor: '#C7C7CC',
// Add more theme properties
};
const App = () => (
<ThemeProvider theme={customTheme}>
<KoreChat botConfig={botConfig} />
</ThemeProvider>
);import { CustomTemplate } from 'rn-kore-bot-sdk-v77';
const MyCustomButton = new CustomTemplate({
templateType: 'custom-button',
render: (data, onAction) => (
<TouchableOpacity
style={styles.customButton}
onPress={() => onAction(data.action)}
>
<Text>{data.title}</Text>
</TouchableOpacity>
),
});
<KoreChat
botConfig={botConfig}
templateInjection={new Map([
['custom-button', MyCustomButton]
])}
/>| Prop | Type | Required | Description |
|---|---|---|---|
botConfig |
BotConfigModel |
β | Bot configuration object |
onListItemClick |
(item: any) => void |
β | Callback for list item interactions |
onHeaderActionsClick |
(action: any) => void |
β | Callback for header action buttons |
templateInjection |
Map<string, CustomTemplate> |
β | Custom template injection map |
themeConfig |
ThemeConfig |
β | Custom theme configuration |
interface BotConfigModel {
// Required fields
botId: string; // Bot identifier
chatBotName: string; // Display name for the bot
serverUrl: string; // Server URL (without trailing slash)
brandingAPIUrl: string; // Branding API URL (without trailing slash)
// Authentication
customerId?: string; // Customer identifier
clientId?: string; // OAuth client ID
clientSecret?: string; // OAuth client secret
identity?: string; // User identity
// Configuration
isAnonymous?: boolean; // Anonymous user mode
isPlatform?: boolean; // Platform integration mode
enableHistory?: boolean; // Chat history feature
allowAttachments?: boolean; // File attachment feature
}The library implements graceful degradation for native modules:
// β
Automatic fallback when modules are unavailable
// β οΈ Logs appropriate warnings for missing features
// π Continues functioning with reduced capabilitiesimport { BotException } from 'rn-kore-bot-sdk-v77';
try {
// Bot operations
} catch (error) {
if (error instanceof BotException) {
console.log('Bot error:', error.message);
}
}The SDK includes voice recognition and text-to-speech capabilities:
| Status | Description | Action Required |
|---|---|---|
| β Granted | Voice features available | None |
| Voice button hidden | Check app settings | |
| π Not Requested | Will prompt on first use | None |
π§ Common Voice Problems
Problem: "Microphone permission denied" Solution:
- Check Info.plist/AndroidManifest.xml permissions
- Reset app permissions in device settings
- Reinstall app to re-trigger permission prompts
Problem: Voice button not appearing Solution:
- Verify
@react-native-voice/voiceinstallation - Check native module linking
- Rebuild project after adding permissions
// β
Success logs
"Voice module loaded successfully"
"Microphone permission granted"
// β οΈ Warning logs
"Voice module not available"
"Microphone permission denied"
"Permissions module not available"- Start with Minimal Installation:
# Install only required dependencies
npm install # (just the minimal set)
npx react-native run-ios- Test Lazy Loading Behavior:
# Try using features without dependencies installed
# - Tap voice button β See "Voice not available" message
# - Play audio β See silent mode
# - Open video β See static thumbnail- Add Features Incrementally:
# Add voice features
npm install @react-native-voice/voice react-native-tts
npx react-native run-ios
# Now voice buttons should appear and workCheck Console Logs:
// Look for these messages in your console:
"LazySound: react-native-sound not installed, using fallback"
"LazyVoice: Voice module loaded successfully"
"LazyVideo: Loading video player..."Visual Indicators:
- π Loading spinners when modules are loading
β οΈ Warning messages for missing dependencies- β Success indicators when features are ready
src/config/BotConfig.tsx- Configuration setupsrc/screens/Home/index.tsx- Integration examplesrc/screens/TestFeatures.tsx- Feature testing screensrc/components/LazyComponents/- Lazy loading examples
Run the complete sample:
cd SampleApp
npm install
npx react-native run-ios # or run-androidWe welcome contributions! Please see our Contributing Guidelines for details.
git clone https://github.com/your-repo/react-native-kore-bot-sdk.git
cd react-native-kore-bot-sdk
npm installnpm run test # Run tests
npm run lint # Lint code
npm run build # Build library
npm run example # Run example appThis project is licensed under the MIT License - see the LICENSE file for details.
Found a bug? Open an issue Have a question? Start a discussion Need enterprise support? Contact Kore.ai
- Choose your approach from the 3 installation options above
- Install dependencies for your chosen features
- Run the app:
npx react-native run-ios - Test lazy loading by trying features without dependencies
- Add more features incrementally as needed
- Start minimal and add features as you need them
- Check console logs to see lazy loading in action
- Test on device for realistic bundle size impact
- Use fallback components to handle missing dependencies gracefully
Made with β€οΈ by the Kore.ai Team