Skip to main content

REFERENCE

Developer Reference

Authentication, APIs, SDKs, Flow Agent processors and parameter resolution, in full.

SDK Overview

Installing, configuring and getting started with the Asgard SDK

Asgard publishes official JavaScript and React SDKs so you can integrate chatbot functionality without handling the underlying API details yourself.

  1. What the SDK gives you​

    • Simplified API access: REST requests are wrapped, with authentication and endpoint configuration handled in one place
    • SSE stream handling: Server-Sent Events are processed for you, so bot responses arrive as they are produced
    • Channel management: session persistence is built in, supporting multi-turn conversations
    • React components: @asgard-js/react ships a ready-made chat UI along with hooks
  2. Installation​

    JavaScript SDK​

    For any JavaScript environment (Node.js, the browser, framework-agnostic):

    npm install @asgard-js/core

    React SDK​

    For React applications, including UI components and hooks:

    npm install @asgard-js/react

    @asgard-js/react takes @asgard-js/core as a peer dependency, so install both.

  3. Quick start​

    This example uses the low-level @asgard-js/core API to send a message and receive a streamed response:

    import { AsgardServiceClient, Channel, Conversation } from '@asgard-js/core';

    const client = new AsgardServiceClient({
    botProviderEndpoint:
    'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
    });

    const conversation = new Conversation({ messages: new Map() });

    const channel = await Channel.reset({
    client,
    customChannelId: 'channel-123',
    conversation,
    statesObserver: (states) => {
    console.log('Messages:', Array.from(states.conversation.messages.values()));
    },
    });

    await channel.sendMessage({ text: 'Hello, tell me about yourself' });

    In React, the <Chatbot> component is the recommended starting point:

    import { Chatbot } from '@asgard-js/react';
    import '@asgard-js/react/style';

    export default function App() {
    return (
    <div style={{ height: '100vh' }}>
    <Chatbot
    title="My AI assistant"
    customChannelId="user-123"
    config={{
    botProviderEndpoint:
    'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
    }}
    />
    </div>
    );
    }
  4. SDK compared with calling the REST API directly​

    CapabilitySDKREST API
    SSE stream handlingHandled for youImplement it yourself
    AuthenticationConfigured once, applied automaticallyAdd the header on every request
    Channel managementSession persistence built inMaintain channelId yourself
    React integrationHooks and components providedWrap it yourself
    Error handlingOne error interfaceParse each kind of error yourself
    TypeScript supportFull type definitionsDefine the types yourself
  5. Further reading​

  6. GitHub​

    Source and releases: asgard-ai-platform/asgard-js-sdk

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us