0.0.1 • Published 1 year ago
@webchatter.ai/com.webchatter.unitysdk v0.0.1
WebChatter Unity Package
This Unity package provides a client for Webchatter.ai, allowing you to integrate chat functionality into your Unity applications.
Installation
- Download the WebChatter Unity package.
- Open your Unity project.
- In the Unity Editor, go to
Assets > Import Package > Custom Package
. - Select the package.json file from downloaded WebChatter Unity package.
- Click "Import" to add the package to your project.
Usage
Initialization
- Obtain your WebChatter.ai ApiKey and ChatId from webchatter.ai/dashboard
- Initialize the WebChatter client with your API Key.
- 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}");
});
}
}
0.0.1
1 year ago