com.webchatter.unitysdk
v0.0.2
Published
This is Unity SDK package to use Webchatter. See documentation on webchatter.ai for more details.
Downloads
3
Maintainers
Readme
WebChatter Unity Package
This Unity package provides a client for Webchatter.ai, allowing you to integrate chat functionality into your Unity applications.
Installation
Editor
- In the Unity Editor, go to
Edit > Project Settings > Package Manager
- Create a New Scoped Registry by entering
Name npmjs
URL https://registry.npmjs.org
Scope(s) com.webchatter
- Open the
Window > Package Manager
and switch toMy Registries
via thePackages
dropdown menu - Select
Webchatter - UnitySDK
and clickinstall
Manifest file (Alternative way)
- Open
Packages/manifest.json
file - Add
scopedRegistries
anddependencies
{
"dependencies": {
...
"com.webchatter.unitysdk": "0.0.1"
},
"scopedRegistries": [
{
"name": "npmjs",
"url": "https://registry.npmjs.org",
"scopes": [
"com.webchatter"
]
}
]
}
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}");
});
}
}