Skip to main content

Navigation

The agent needs two things to navigate your app well: to know where the user currently is, and to know what each screen is for. AppilotsNavigationContainer handles the first; registerScreen handles the second.

AppilotsNavigationContainer

AppilotsNavigationContainer wraps your React Navigation <NavigationContainer> from the outside. It automatically injects ref and onStateChange to track the active route and forward it to Appilots, so the agent's navigate actions can target real routes and every chat message carries "where the user is" as part of its context.

import { NavigationContainer } from '@react-navigation/native';
import { AppilotsProvider, AppilotsNavigationContainer, AppilotsChat } from '@appilots/sdk';

function App() {
return (
<AppilotsProvider>
<AppilotsNavigationContainer>
<NavigationContainer>
<Stack.Navigator>
{/* your screens */}
</Stack.Navigator>
</NavigationContainer>
</AppilotsNavigationContainer>
<AppilotsChat />
</AppilotsProvider>
);
}

If your NavigationContainer already has its own ref or onStateChange (for analytics, deep linking, etc), AppilotsNavigationContainer forwards to them — you don't lose your existing handlers by adding this wrapper.

registerScreen

registerScreen(metadata) describes a screen to the agent: what it's for, what fields and actions live on it, and which prompts to suggest when the chat opens there. Call it once per screen — at the top of the screen component, or from a shared registry file.

import { registerScreen } from '@appilots/sdk';

registerScreen({
name: 'VehicleCreate',
title: 'New Vehicle',
description: 'Form to register a new vehicle for the account.',
fields: [{ id: 'plate', label: 'License Plate', type: 'text', required: true }],
actions: [{ id: 'submitVehicle', label: 'Save Vehicle', type: 'submit', effect: 'write', riskLevel: 'low' }],
suggestedPrompts: ['Add a vehicle'],
});

ScreenMetadata

FieldTypeDescription
namestringRequired. Must match the React Navigation route name.
titlestringHuman-readable screen title.
descriptionstringWhat this screen does — helps the agent decide when to navigate here.
actions(string | ScreenActionMetadata)[]Actions available on this screen. See below.
fieldsScreenFieldMetadata[]Form fields available on this screen. See below.
formFieldsstring[]Legacy simple list of field names. Prefer fields.
tagsstring[]Free-form tags for categorization.
suggestedPromptsstring[]Chips shown when the chat opens on this screen. These have the highest priority — they beat server-mined popular prompts.

ScreenActionMetadata

FieldTypeDescription
idstringAction identifier the agent references.
labelstringHuman-readable label — should match the UI.
type'submit' | 'button' | 'link' | stringAction type.
targetScreenstringDestination screen, for navigation/link actions, when known.
requiresConfirmationbooleanForces a confirmation card before this action executes.
effect'read' | 'write' | 'destructive' | stringWhat kind of effect this action has.
riskLevel'low' | 'medium' | 'high' | stringRisk level used alongside effect to decide how cautious the agent should be.
destructivebooleanMarks the action as destructive.

See Agent actions for how the agent uses effect, riskLevel, and requiresConfirmation to decide when to ask for approval.

ScreenFieldMetadata

FieldTypeDescription
idstringField identifier the agent references.
labelstringHuman-readable label — should match the UI.
type'text' | 'number' | 'select' | 'toggle' | 'date' | stringField type.
requiredbooleanWhether the field is required.
options{ label: string; value: string }[]Options for select fields.

registerScreen vs. registering elements

registerScreen describes the screen — its purpose, its fields, and its actions, as metadata the agent reads. It does not make anything operable by itself. To let the agent actually fill a field or press a button, you also need to register the underlying component — via auto-tracking, a hook, or an HOC. See Registering elements for those three approaches.

Next steps