Created
May 15, 2018 14:32
-
-
Save akeller/a7f5b41720bab384e7951dadee417e3e to your computer and use it in GitHub Desktop.
Initiation Watson Assistant with the Watson Unity SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//******************************************* | |
//You may have initiated Watson Conversation with the Watson Unity SDK previously like this, within the start function with a string. | |
//******************************************* | |
void Start() | |
{ | |
//enter username and password as a string | |
Credentials credentials = new Credentials(<username>, <password>, "https://gateway.watsonplatform.net/conversation/api"); | |
Conversation _conversation = new Conversation(credentials); | |
//be sure to give it a Version Date | |
_conversation.VersionDate = "2017-05-26"; | |
//enter workspace_id as string | |
if (!_conversation.Message(OnMessage, OnFail, <workspace_id>, "Hi!")) | |
{ | |
Log.Debug("ExampleConversation.Message()", "Failed to message!"); | |
} | |
} | |
//******************************************* | |
//Now, with Watson Assistant, the Watson Unity SDK abstraction for an Assistant message doesn't take a simple string. You'll need to create an object. This snippet is wrapped in a function I can call, but very similar to the above snippet. | |
//******************************************* | |
//Initiate a conversation | |
private void Message0() | |
{ | |
inputObj.Add("text", outputText); | |
MessageRequest messageRequest = new MessageRequest() | |
{ | |
Input = inputObj | |
}; | |
if (!_assistant.Message(OnMessage, OnFail, assistantWorkspace, messageRequest)) | |
Log.Debug("ExampleAssistant.Message()", "Failed to message!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment