New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@serviceagent/nextjs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serviceagent/nextjs

ServiceAgent Next.js integration — provider, server client, webhook handler, and middleware

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@serviceagent/nextjs

Next.js integration for ServiceAgent — provider, server client, webhook handler, and all React components.

Install

npm install @serviceagent/nextjs

Quick Start

1. Add Provider to Layout

// app/layout.tsx
import { ServiceAgentProvider } from '@serviceagent/nextjs';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <ServiceAgentProvider>{children}</ServiceAgentProvider>
      </body>
    </html>
  );
}

This adds the chat widget to every page. Set environment variables:

NEXT_PUBLIC_SERVICEAGENT_WIDGET_KEY=wid_xxxxx
NEXT_PUBLIC_SERVICEAGENT_API_URL=https://process.serviceagent.ai
SERVICEAGENT_API_KEY=your_api_key

2. Server-side SDK

// In server components or API routes
import { createServiceAgentClient } from '@serviceagent/nextjs/server';

const sa = createServiceAgentClient();
const results = await sa.searchKnowledgeBase('How to reset password?');

3. Webhook Handler

// app/api/serviceagent/webhooks/route.ts
import { handleWebhook } from '@serviceagent/nextjs/server';

export const POST = handleWebhook({
  'contact.created': async (event) => {
    console.log('New contact:', event.data);
  },
  'appointment.created': async (event) => {
    console.log('New booking:', event.data);
  },
});

4. Calendar Booking

import { CalendarBooking } from '@serviceagent/nextjs';

export default function BookingPage() {
  return <CalendarBooking bookingKey="your_booking_key" />;
}

5. Voice Agent

import { VoiceAgent } from '@serviceagent/nextjs';

export default function CallPage() {
  return <VoiceAgent token="session_token" orgId="org_id" />;
}

Exports

Client (@serviceagent/nextjs)

  • ServiceAgentProvider — Layout provider with chat widget
  • Chat, ChatIframe — Chat widget components
  • CalendarBooking — Calendar booking widget
  • VoiceAgent — Voice agent component
  • useServiceAgent — Chat control hook
  • All AIVA voice hooks and components

Server (@serviceagent/nextjs/server)

  • createServiceAgentClient() — Server-side SDK client
  • handleWebhook(handlers) — Webhook route handler factory
  • ServiceAgent — SDK class (re-exported)

License

MIT

Keywords

serviceagent

FAQs

Package last updated on 28 Mar 2026

Related posts