com.webchatter.unitysdk

0.0.2 • Public • Published

WebChatter Unity Package

This Unity package provides a client for Webchatter.ai, allowing you to integrate chat functionality into your Unity applications.

Installation

Editor

  1. In the Unity Editor, go to Edit > Project Settings > Package Manager
  2. Create a New Scoped Registry by entering
Name        npmjs
URL         https://registry.npmjs.org
Scope(s)    com.webchatter
  1. Open the Window > Package Manager and switch to My Registries via the Packages dropdown menu
  2. Select Webchatter - UnitySDK and click install

Manifest file (Alternative way)

  1. Open Packages/manifest.json file
  2. Add scopedRegistries and dependencies
{
    "dependencies": {
        ...
        "com.webchatter.unitysdk": "0.0.1"
    },
    "scopedRegistries": [
    {
      "name": "npmjs",
      "url": "https://registry.npmjs.org",
      "scopes": [
        "com.webchatter"
      ]
    }
  ]
}

Usage

Initialization

  1. Obtain your WebChatter.ai ApiKey and ChatId from webchatter.ai/dashboard
  2. Initialize the WebChatter client with your API Key.
  3. Ask question and listen for answer.

Exapmle

using UnityEngine;
using Webchatter;

public class ChatService : MonoBehaviour
{
    private WebchatterClient _webchatterClient;

    public void InitializeClient(string chatId, string apiKey)
    {
        _webchatterClient = gameObject.AddComponent<WebchatterClient>();
        _webchatterClient.OnWebchatterInitialized.AddListener( () => Debug.Log("Webchatter initialized correctly"));
        _webchatterClient.Initialize(chatId, apiKey);
    }
    
    public void AskChat(string message)
    {
        _webchatterClient.Qa(message, 
            (data) =>
            {
                // e.g. _uiText.text += data
            }, 
            (endMessage) =>
            {
                Debug.Log($"End Message. Full answer: {endMessage}");
            });
    }
}

Package Sidebar

Install

npm i com.webchatter.unitysdk

Version

0.0.2

License

ISC

Unpacked Size

13.7 kB

Total Files

29

Last publish

Collaborators

  • webchatter