Quick Start

Quick Start Tutorial

Get your first AI bot up and running in under 10 minutes. This tutorial will walk you through the essential steps to integrate AI Nexus Pro into your application.

Estimated time: 10 minutesDifficulty: Beginner

Quick Start Steps

Follow these four simple steps to get your AI bot running in minutes.

1

Initialize Client

Set up the AI Nexus Pro client with your API key

2 min
2

Send First Message

Send your first message to the AI chatbot

3 min
3

Handle Response

Process and display the AI response

2 min
4

Test Voice Bot

Try the voice bot functionality

3 min

Code Examples

Copy and paste these examples to get started quickly with your preferred language.

javascript

// 1. Initialize the client
import { AINexusClient } from '@ainexuspro/sdk';

const client = new AINexusClient({
  apiKey: process.env.AINEXUS_API_KEY,
  environment: 'production'
});

// 2. Send your first message
async function sendMessage() {
  try {
    const response = await client.chat.send({
      message: 'Hello! How can you help me today?',
      sessionId: 'user_123',
      context: {
        userId: 'user_456',
        timestamp: new Date().toISOString()
      }
    });
    
    console.log('AI Response:', response.reply);
    return response.reply;
  } catch (error) {
    console.error('Error:', error);
  }
}

// 3. Handle the response
sendMessage().then(reply => {
  // Display the AI response to your user
  document.getElementById('chat-output').textContent = reply;
});

python

# 1. Initialize the client
from ainexuspro import AINexusClient
import os

client = AINexusClient(
    api_key=os.getenv('AINEXUS_API_KEY'),
    environment='production'
)

# 2. Send your first message
async def send_message():
    try:
        response = await client.chat.send(
            message="Hello! How can you help me today?",
            session_id="user_123",
            context={
                "user_id": "user_456",
                "timestamp": "2024-01-15T10:30:00Z"
            }
        )
        
        print('AI Response:', response.reply)
        return response.reply
    except Exception as error:
        print('Error:', error)

# 3. Handle the response
reply = await send_message()
# Display the AI response to your user
print(f"AI says: {reply}")

react

// React component example
import React, { useState } from 'react';
import { AINexusClient } from '@ainexuspro/sdk';

const ChatBot = () => {
  const [message, setMessage] = useState('');
  const [response, setResponse] = useState('');
  const [loading, setLoading] = useState(false);

  const client = new AINexusClient({
    apiKey: process.env.REACT_APP_AINEXUS_API_KEY,
    environment: 'production'
  });

  const sendMessage = async () => {
    setLoading(true);
    try {
      const result = await client.chat.send({
        message,
        sessionId: 'user_123'
      });
      setResponse(result.reply);
    } catch (error) {
      console.error('Error:', error);
    } finally {
      setLoading(false);
    }
  };

  return (
    <div className="chat-container">
      <input 
        value={message}
        onChange={(e) => setMessage(e.target.value)}
        placeholder="Type your message..."
      />
      <button onClick={sendMessage} disabled={loading}>
        {loading ? 'Sending...' : 'Send'}
      </button>
      {response && <div className="response">{response}</div>}
    </div>
  );
};

Voice Bot Integration

Add voice capabilities to your application with our voice bot API.

Voice Bot Setup

Start a voice session and handle speech input/output

// Voice Bot Integration
async function startVoiceSession() {
  try {
    const session = await client.voice.start({
      language: 'en-US',
      voiceModel: 'nova',
      sessionId: 'voice_session_123'
    });
    
    console.log('Voice session started:', session.sessionId);
    
    // Handle voice input/output
    session.on('speech', (transcript) => {
      console.log('User said:', transcript);
    });
    
    session.on('response', (audioData) => {
      // Play the AI response audio
      playAudio(audioData);
    });
    
  } catch (error) {
    console.error('Voice session error:', error);
  }
}

Congratulations! 🎉

You've successfully set up your first AI bot! Now let's explore more advanced features.

Quick Help

Ask me anything about this page

Ready to help