diff --git a/Config.json.enc b/Config.json.enc index 880bbb6cf..104d85fe6 100644 Binary files a/Config.json.enc and b/Config.json.enc differ diff --git a/Examples/ServiceExamples/Scripts/ExampleConversation.cs b/Examples/ServiceExamples/Scripts/ExampleConversation.cs index 0093655bc..9c40ee2c1 100644 --- a/Examples/ServiceExamples/Scripts/ExampleConversation.cs +++ b/Examples/ServiceExamples/Scripts/ExampleConversation.cs @@ -22,7 +22,7 @@ public class ExampleConversation : MonoBehaviour { private Conversation m_Conversation = new Conversation(); - private string m_WorkspaceID = "car_demo_1"; + private string m_WorkspaceID = "25dfa8a0-0263-471b-8980-317e68c30488"; private string m_Input = "Can you unlock the door?"; void Start () { @@ -32,9 +32,17 @@ void Start () { void OnMessage (DataModels.MessageResponse resp) { - foreach(DataModels.MessageIntent mi in resp.intents) - Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence); - - Debug.Log("response: " + resp.output.text); + if(resp != null) + { + foreach(DataModels.MessageIntent mi in resp.intents) + Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence); + + if(resp.output != null && !string.IsNullOrEmpty(resp.output.text)) + Debug.Log("response: " + resp.output.text); + } + else + { + Debug.Log("Failed to invoke Message();"); + } } } diff --git a/Examples/ServiceExamples/ServiceExamples.unity b/Examples/ServiceExamples/ServiceExamples.unity index 769ae2f86..9f6a70ec0 100644 --- a/Examples/ServiceExamples/ServiceExamples.unity +++ b/Examples/ServiceExamples/ServiceExamples.unity @@ -249,6 +249,45 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 6 +--- !u!1 &748186939 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 748186941} + - 114: {fileID: 748186940} + m_Layer: 0 + m_Name: ExampleAlchemyLanguage + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &748186940 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748186939} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9d5294a7b05214c5690d02420b87a821, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &748186941 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748186939} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 299.5, y: 291.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 11 --- !u!1 &859102722 GameObject: m_ObjectHideFlags: 0 @@ -538,7 +577,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &2004886372 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Scripts/Services/Conversation/Conversation.cs b/Scripts/Services/Conversation/Conversation.cs index 84b0a2e51..4e2cca936 100644 --- a/Scripts/Services/Conversation/Conversation.cs +++ b/Scripts/Services/Conversation/Conversation.cs @@ -57,7 +57,7 @@ public class Conversation : IWatsonService private const string SERVICE_ID = "ConversationV1"; private static fsSerializer sm_Serializer = new fsSerializer(); #endregion - + /* #region Workspaces /// /// Gets the available workspaces for the Conversation service @@ -113,8 +113,9 @@ private void OnGetWorkspacesResp(RESTConnector.Request req, RESTConnector.Respon ((GetWorkspacesReq)req).Callback(resp.Success ? workspaces : null); } #endregion - + */ #region Message + private const string SERVICE_MESSAGE = "/v1/workspaces"; /// /// Message the specified workspaceId, input and callback. /// @@ -130,7 +131,7 @@ public bool Message(string workspaceId, string input, OnMessage callback) if(callback == null) throw new ArgumentNullException("callback"); - RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, "/v2/rest/workspaces"); + RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_MESSAGE); if(connector == null) return false; @@ -140,6 +141,8 @@ public bool Message(string workspaceId, string input, OnMessage callback) MessageReq req = new MessageReq(); req.Callback = callback; req.Headers["Content-Type"] = "application/json"; + req.Headers["Accept"] = "application/json"; + req.Parameters["version"] = DataModels.CONVERSATION_VERSION; req.Function = "/" + workspaceId + "/message"; req.Send = Encoding.UTF8.GetBytes(reqString); req.OnResponse = MessageResp; @@ -227,18 +230,19 @@ public CheckServiceStatus(Conversation service, ServiceStatus callback) if (!string.IsNullOrEmpty(customServiceID)) { - if (!m_Service.Message(customServiceID, "Hello", OnMessage)) + if (!m_Service.Message(customServiceID, "Ping", OnMessage)) OnFailure("Failed to invoke Converse()."); else m_ConversationCount += 1; } else { - if (!m_Service.GetWorkspaces(OnGetWorkspaces)) - OnFailure("Failed to invoke GetDialogs()."); +// if (!m_Service.GetWorkspaces(OnGetWorkspaces)) +// OnFailure("Failed to invoke GetDialogs()."); + OnFailure("Please define a workspace variable in config.json (" + SERVICE_ID + "_ID)"); } } - + /* private void OnGetWorkspaces(DataModels.Workspaces workspaces) { if (m_Callback != null) @@ -254,7 +258,7 @@ private void OnGetWorkspaces(DataModels.Workspaces workspaces) else OnFailure("GetMessages() failed."); } - + */ private void OnMessage(DataModels.MessageResponse resp) { if (m_ConversationCount > 0) diff --git a/Scripts/Services/Conversation/DataModels.cs b/Scripts/Services/Conversation/DataModels.cs index a79944a1d..124b358fc 100644 --- a/Scripts/Services/Conversation/DataModels.cs +++ b/Scripts/Services/Conversation/DataModels.cs @@ -19,6 +19,7 @@ namespace IBM.Watson.DeveloperCloud.Services.Conversation.v1 { public class DataModels { + public const string CONVERSATION_VERSION = "2016-05-19"; #region Workspaces /// /// Workspaces.