Skip to main content
A complete, ready-to-use chat interface with support for text, images, and voice messages. Everything is handled for you automatically: WebSocket connection, message history, media uploads, and UI.

Installation

npm install @upliftai/syngenta-assistant-rn

Required Peer Dependencies

Install the following dependencies in your Expo project:
npx expo install \
  react-native-reanimated \
  react-native-gesture-handler \
  react-native-safe-area-context \
  react-native-keyboard-controller \
  react-native-worklets \
  expo-audio \
  expo-file-system \
  expo-haptics \
  expo-image \
  expo-image-picker \
  @expo/vector-icons

Compatibility

RequirementVersion
Expo SDK54+
React Native0.81+
React19+
iOS13.4+
Android API23+
This SDK requires the New Architecture to be enabled.

Quick Start

The SDK exports two components: a Provider and a Screen. Wrap your app with the provider, then render the chat screen wherever you need it.
import {
  SyngentaAssistantProvider,
  SyngentaChatScreen
} from '@upliftai/syngenta-assistant-rn';

export default function App() {
  return (
    <SyngentaAssistantProvider token="your-auth-token">
      <SyngentaChatScreen />
    </SyngentaAssistantProvider>
  );
}
That’s it. The chat screen handles everything: WebSocket connection, message history, media uploads, and UI.

API Reference

SyngentaAssistantProvider

Context provider that configures the SDK. Must wrap any screen that renders SyngentaChatScreen.
<SyngentaAssistantProvider
  token="your-auth-token"
  apiBaseUrl="https://api.example.com"
>
  {children}
</SyngentaAssistantProvider>
token
string
required
Authentication token for API access
apiBaseUrl
string
Custom API server URL. Defaults to the staging server.
children
ReactNode
required
Child components

SyngentaChatScreen

A complete chat interface component. Renders a full-screen chat experience with no configuration required.
<SyngentaChatScreen />

Message List

Automatic scrolling and history loading

Text Input

Text input with send button

Image Picker

Camera and gallery support

Voice Recording

Gesture-controlled audio recording

Connection Status

Real-time connection indicators

Theming

Dark and light mode support

Integration Examples

import { Stack } from 'expo-router';
import { SyngentaAssistantProvider } from '@upliftai/syngenta-assistant-rn';

export default function RootLayout() {
  const authToken = useAuthToken(); // your auth logic

  return (
    <SyngentaAssistantProvider token={authToken}>
      <Stack>
        <Stack.Screen name="index" />
        <Stack.Screen
          name="chat"
          options={{
            presentation: 'modal',
            headerShown: false,
          }}
        />
      </Stack>
    </SyngentaAssistantProvider>
  );
}

Features

Type messages using the text input at the bottom of the screen. Press the send button or use the keyboard return key to send.
Tap the image button to:
  • Take a photo with the camera
  • Select an image from the gallery
Images can include an optional caption before sending.
Press and hold the microphone button to record a voice message:
  • Hold to start recording
  • Release to send the recording
  • Slide left while holding to cancel
The minimum recording duration is 750ms. Shorter recordings are automatically cancelled.
A banner appears at the top of the chat when:
StatusMeaning
ConnectingEstablishing connection to server
DisconnectedConnection lost, will retry automatically
Loading Previous MessagesFetching message history
ErrorConnection failed
The chat interface automatically adapts to the system appearance:
  • Light mode: Beige background with green sent messages
  • Dark mode: Dark background with teal sent messages

Permissions

Configure the following permissions in your app.json for full functionality:
{
  "expo": {
    "plugins": [
      [
        "expo-image-picker",
        {
          "photosPermission": "Allow $(PRODUCT_NAME) to access your photos.",
          "cameraPermission": "Allow $(PRODUCT_NAME) to access your camera."
        }
      ],
      [
        "expo-audio",
        {
          "microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone."
        }
      ]
    ]
  }
}

Troubleshooting

The SyngentaChatScreen must be rendered inside a SyngentaAssistantProvider:
Correct - Wrap with provider:
<SyngentaAssistantProvider token="...">
  <SyngentaChatScreen />
</SyngentaAssistantProvider>
Wrong - Missing provider:
<SyngentaChatScreen />
1

Verify token

Check that your authentication token is valid and not expired
2

Check network

Verify network connectivity on the device
3

Custom URL

If using a custom apiBaseUrl, ensure the server is reachable
1

Configure permissions

Ensure microphone permissions are configured in app.json
2

Grant access

The user must grant microphone access when prompted
3

Verify installation

Check that expo-audio is properly installed
1

Configure permissions

Ensure image picker permissions are configured in app.json
2

Grant access

The user must grant photo library/camera access when prompted
3

Verify installation

Check that expo-image-picker is properly installed
These libraries require additional setup:
1

Add Babel plugin

Add the Reanimated babel plugin to babel.config.js:
module.exports = {
  presets: ['babel-preset-expo'],
  plugins: [
    ...
    'react-native-reanimated/plugin' // last item in list
  ],
};
2

Clear cache

Clear the bundler cache after changes:
npx expo start --clear
Ensure your TypeScript version is compatible and that you have the latest type definitions:
npm install -D @types/react @types/react-native