Contents Menu Expand
Logo
Web (React, Angular, etc.) Objective-C Swift Kotlin Java Flutter Ionic React Native
Go to docs
Logo
Logo

Getting Started

  • About Alan AI
  • Quick start
    • Review the project scope
    • Sign up for Alan AI Studio
    • Create a static corpus
    • Create a dynamic corpus
    • Understand AI reasoning
    • Adjust AI reasoning and output
    • Integrate with the app
    • Customize the Agentic Interface look and feel
    • Add actionable links
    • Analyze user queries
  • Recent Alan AI Platform updates

Alan AI Deployment

  • Alan AI Platform
  • Deployment options
    • SaaS deployment
    • Private cloud/on-premises deployment
      • Alan AI Cloud deployment
      • Troubleshooting
      • Alan AI Helm installation package
      • Alan AI Cloud configuration
        • Alan AI configuration options
        • Enabling GitHub integration
        • Switching the AI model

Alan AI Studio

  • Agentic Interface projects
  • Dialog scripts
    • Managing scripts
    • Exporting and importing scripts
    • Using shortcuts
    • Customizing the code editor
  • Versions and environments
  • Resources
  • Collaboration and CI/CD tools
    • Sharing and keeping scripts in GitHub
    • Setting up CI/CD workflow
  • Testing and debugging
    • Debugging Chat
    • Tools to simulate in-app behavior
    • Test View
    • Alan AI Studio logs
    • In-app testing
  • Agentic Interface Analytics
    • Projects dashboard
    • Analytics View
  • Cohorts
  • Billing and subscriptions
    • Adding funds
    • Applying promo codes
    • Creating organizations
  • Alan AI Browser Plugin

Alan AI Agentic Interface

  • Alan AI Agentic Interface
  • Customization options
  • Likes and dislikes feedback setup
  • Agentic Interface history
  • Agentic Interface activation

Server API

  • Data corpuses
    • Static corpus
    • Dynamic corpus
    • Puppeteer crawler
    • Crawling depth
    • Corpus priority
    • Corpus filtering
    • Corpus includes and excludes
    • Protected resources
    • Crawler tasks
    • Corpus Explorer
  • Transforms
    • Transform configuration
    • Transform instructions and examples
    • Static corpus transforms
    • Dynamic corpus transforms
    • Puppeteer transforms
    • Intent transforms
    • Function import
    • Transforms Explorer
  • Action Transformer
    • UI context
    • Action execution
    • Data merging
    • Action Transformer API
  • Automated UI generation
    • Chart generation
  • Explainable AI
    • Visual graphs
  • Semantic search
    • Table API
  • Error handling and fallbacks
    • Fallback function
    • Fallback transforms
  • Intent-driven dialogs
    • User commands
      • Patterns
      • Intent matching
      • Play options
      • Voice settings
    • Slots
    • Contexts
    • Predefined script objects
    • User data
      • User events
      • Client object
    • Lifecycle callbacks
  • Sending data from the app
    • authData
    • Visual state
    • Project API
  • Built-in JavaScript libraries
  • UI widgets
    • Chat cards
    • Chat buttons
    • Alan AI agentic interface popups
  • API reference

Integration

  • Integration overview
  • Web frameworks
    • React
    • Angular
    • Vue
    • Ember
    • JavaScript
    • Electron
    • Cross-platform solutions
    • Server-side rendering
  • iOS
  • Android
  • Cross-platform frameworks
    • Flutter
    • Ionic
      • Ionic React
      • Ionic Angular
      • Ionic Vue
      • iOS and Android deployment
      • Communication between components
      • Troubleshooting
    • React Native
    • Apache Cordova

Alan AI SDK Toolkit

  • Client API methods
  • Alan AI handlers
    • onCommand handler
    • onButtonState handler
    • onConnectionStatus handler
    • onEvent handler

Samples & Tutorials

  • How-tos
  • Tutorials
    • Alan AI Agentic Interface
      • Create an Agentic Interface for a website
      • Add a greeting to the Agentic Interface
      • Use buttons in the Agentic Interface
    • Web
      • Building a voice Agentic Interface for web
      • Making a Web API call from the dialog script
    • Web frameworks
      • Building a voice Agentic Interface for a React app
      • Building a voice Agentic Interface for an Angular app
      • Building a voice Agentic Interface for a Vue app
      • Building a voice Agentic Interface for an Ember app
      • Building a voice Agentic Interface for an Electron app
    • iOS
      • Building a voice Agentic Interface for an iOS app
      • Navigating between views
      • Passing the app state to the dialog script
      • Highlighing items with voice
      • Triggering dialog script actions without commands
      • Playing a greeting in an app
    • Android
      • Building a voice Agentic Interface for an Android Java or Kotlin app
      • Navigating in an Android app with voice (Kotlin)
      • Passing the app state to the dialog script (Kotlin)
      • Sending data from the app to the dialog script (Kotlin)
    • Flutter
      • Building a voice Agentic Interface for a Flutter app
      • Navigating between screens
      • Passing the app state to the dialog script
      • Sending data to the dialog script
    • Ionic
      • Building a voice Agentic Interface for an Ionic Angular app
      • Navigating between tabs (Ionic Angular)
      • Passing the app state to the dialog script (Ionic Angular)
      • Building a voice Agentic Interface for an Ionic React app
      • Navigating between tabs (Ionic React)
    • React Native
      • Building a voice Agentic Interface for a React Native app
      • Sending commands to the app
      • Passing the app state to the dialog script
      • Triggering activities without voice commands
      • Navigating between screens with voice
  • FAQ

Navigating between tabs (Ionic React)¶

If your Ionic React app has several tabs, you can add voice commands to navigate through the app. In this tutorial, we will use a simple Ionic app with three tabs to demonstrate how to use voice commands to switch between them.

What you will learn¶

  • How to send commands from the dialog script to an Ionic React app

  • How to set up the Alan AI’s event listener and handle commands on the app side

  • How to navigate between tabs in an Ionic React app with voice

What you will need¶

To go through this tutorial, make sure the following prerequisites are met:

  • You have completed the following tutorial: Building a voice Agentic Interface for an Ionic React app.

  • The environment for using the Ionic framework is properly set up. For details, see Ionic documentation.

We will use an example Ionic React app provided by Alan AI. You can also use your own app with several tabs. Make sure you have added the Alan AI agentic interface to the app as described in the previous tutorial.

Note

In this tutorial, we use Ionic React Router to navigate in the app. This component is already added to the example Alan AI app. If you prefer using your own app for this tutorial, make sure it has Ionic React Router. For details, see Ionic documentation.

Step 1: Add voice commands for navigation¶

We need to add a new command to the dialog script to navigate between tabs with voice. In Alan AI Studio, open the project and in the code editor, add the following intent:

Dialog script¶
const ordinalsMap = {
    "first": 1,
    "second": 2,
    "third": 3,
};

intent('Go to the $(TAB: first, second, third..) tab', p => {
    if (ordinalsMap.hasOwnProperty(p.TAB.value)) {
        let tabNumber =  ordinalsMap[p.TAB.value];
        p.play({command: 'navigation', tabNumber: tabNumber});
        p.play(`Opening the ${p.TAB.value} tab`);
    } else {
        p.play('The tab with this number is not found');
    }
});

The user can now give a voice command to go to a specific tab in the app. In the intent, we use the TAB slot. This slot allows us to catch the ordinal number in the user utterance. If the caught number is first, second or third, the navigation command and the tab number will be sent from the dialog script to the app. If the voice command contains some other number, the Agentic Interface will report that such tab is not found.

Step 2: Handle commands on the app side¶

Now, when we say, for example, Go to the second tab, Alan AI sends the navigation command and the 2 tab number to the app. We need to handle this command on the app side and make sure the app opens the necessary tab when the command is received.

In the Ionic app, go to src/components and open the AlanBtn.tsx file. In the useEffect hook, we have the code for the Alan AI agentic interface event listener. Here we subscribe to events received from the dialog script and define how our app must react to these events.

Let’s update the if block for the event listener:

AlanBtn.tsx¶
const AlanBtn: React.FC = (props: any) => {
  const alanBtnComponent = useRef<any>(null);

  useEffect(() => {
    alanBtnComponent.current.addEventListener('command', (data: CustomEvent) => {
      const commandData = data.detail;
      /* If the navigation command is received, go to the tab with the specified number */
      if (commandData.command === 'navigation') {
        props.history.push(`/tab${commandData.tabNumber}`);
      }
    });
  }, []);

  return <alan-button ref={alanBtnComponent} alan-key="YOUR_KEY_FROM_ALAN_STUDIO_HERE" />;
};

Here is how it works: when our app receives the navigation command from the dialog script, we use the push method to go to the tab having the number obtained from the user utterance.

You can test it: run the app, click the Alan AI agentic interface and say: Go to the second tab. The app will open the second tab. Then say: Go to the fifth tab. The Agentic Interface will reply: The tab with this number is not found.

Next
React Native tutorials
Previous
Building a voice Agentic Interface for an Ionic React app
®2025 Alan AI, Inc. All rights reserved.
On this page
  • Navigating between tabs (Ionic React)
    • What you will learn
    • What you will need
    • Step 1: Add voice commands for navigation
    • Step 2: Handle commands on the app side