Found in the service examples working script dialog. Thanks again @Taj!
I feel very close to make it work. I did the same on Raspberry Pi with TJBot, so I have all the accounts, and I correctly linked all the credentials, including the workstation ID, from the Conversation tool. I am using Unity 3D 5.5.1f1 and the latest SDK, the one that was updated 13 days ago.
I copied and pasted a sample conversation code on the gigub page on the SDK into a new C # file:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
public class test : MonoBehaviour {
private Conversation m_Conversation = new Conversation();
private string m_WorkspaceID = "my ID on the conversation tooling site";
private string m_Input = "Hi Alex";
void Start () {
Debug.Log("User: " + m_Input);
m_Conversation.Message(OnMessage, m_WorkspaceID, m_Input);
}
void Update () {
}
void OnMessage(MessageResponse resp, string customData)
{
}
}
In the process of finding out, I realized that the onMessage function does not have a parameter (string customData), I added this with the help of my friends.
Question Part II:
! , . , , , , IBM github.
https://github.com/watson-developer-cloud/unity-sdk#conversation
Message Watson/Scripts/Services/convers.cs:
public bool Message(OnMessage callback, string workspaceID, string input, string customData = default(string))
{
if (string.IsNullOrEmpty(workspaceID))
throw new ArgumentNullException("workspaceId");
if (string.IsNullOrEmpty(input))
throw new ArgumentNullException("input");
if (callback == null)
throw new ArgumentNullException("callback");
RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_MESSAGE);
if (connector == null)
return false;
string reqJson = "{{\"input\": {{\"text\": \"{0}\"}}}}";
string reqString = string.Format(reqJson, input);
MessageReq req = new MessageReq();
req.Callback = callback;
req.Headers["Content-Type"] = "application/json";
req.Headers["Accept"] = "application/json";
req.Parameters["version"] = Version.VERSION;
req.Function = "/" + workspaceID + "/message";
req.Data = customData;
req.Send = Encoding.UTF8.GetBytes(reqString);
req.OnResponse = MessageResp;
return connector.Send(req);
}
, , , callback =/.
! , !