0.0.1 • Published 1 year ago

@webchatter.ai/com.webchatter.unitysdk v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

WebChatter Unity Package

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

Installation

  1. Download the WebChatter Unity package.
  2. Open your Unity project.
  3. In the Unity Editor, go to Assets > Import Package > Custom Package.
  4. Select the package.json file from downloaded WebChatter Unity package.
  5. Click "Import" to add the package to your project.

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}");
            });
    }
}