Skip to content

Commit 4396608

Browse files
committed
chore(Assistant V2): Removed MiniJson using statement, updated examples for AssistantV2
1 parent 92b4c67 commit 4396608

File tree

3 files changed

+97
-10
lines changed

3 files changed

+97
-10
lines changed

Examples/ServiceExamples/Scripts/ExampleAssistantV2.cs

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public class ExampleAssistantV2 : MonoBehaviour
5757
private Assistant _service;
5858

5959
private bool _createSessionTested = false;
60-
private bool _messageTested = false;
60+
private bool _messageTested0 = false;
61+
private bool _messageTested1 = false;
62+
private bool _messageTested2 = false;
63+
private bool _messageTested3 = false;
64+
private bool _messageTested4 = false;
6165
private bool _deleteSessionTested = false;
6266
private string _sessionId;
6367

@@ -104,23 +108,83 @@ private IEnumerator CreateService()
104108

105109
private IEnumerator Examples()
106110
{
107-
Log.Debug("ExampleAssistantV2.Examples()", "Attempting to CreateSession");
111+
Log.Debug("ExampleAssistantV2.RunTest()", "Attempting to CreateSession");
108112
_service.CreateSession(OnCreateSession, OnFail, _assistantId);
109113

110114
while (!_createSessionTested)
111115
{
112116
yield return null;
113117
}
114118

115-
Log.Debug("ExampleAssistantV2.Examples()", "Attempting to Message");
116-
_service.Message(OnMessage, OnFail, _assistantId, _sessionId);
119+
Log.Debug("ExampleAssistantV2.RunTest()", "Attempting to Message");
120+
_service.Message(OnMessage0, OnFail, _assistantId, _sessionId);
117121

118-
while (!_messageTested)
122+
while (!_messageTested0)
119123
{
120124
yield return null;
121125
}
122126

123-
Log.Debug("ExampleAssistantV2.Examples()", "Attempting to DeleteSession");
127+
Log.Debug("ExampleAssistantV2.RunTest()", "Are you open on Christmas?");
128+
MessageRequest messageRequest1 = new MessageRequest()
129+
{
130+
Input = new MessageInput()
131+
{
132+
Text = "Are you open on Christmas?"
133+
}
134+
};
135+
_service.Message(OnMessage1, OnFail, _assistantId, _sessionId, messageRequest1);
136+
137+
while (!_messageTested1)
138+
{
139+
yield return null;
140+
}
141+
142+
Log.Debug("ExampleAssistantV2.RunTest()", "What are your hours?");
143+
MessageRequest messageRequest2 = new MessageRequest()
144+
{
145+
Input = new MessageInput()
146+
{
147+
Text = "What are your hours?"
148+
}
149+
};
150+
_service.Message(OnMessage2, OnFail, _assistantId, _sessionId, messageRequest2);
151+
152+
while (!_messageTested2)
153+
{
154+
yield return null;
155+
}
156+
157+
Log.Debug("ExampleAssistantV2.RunTest()", "I'd like to make an appointment for 12pm.");
158+
MessageRequest messageRequest3 = new MessageRequest()
159+
{
160+
Input = new MessageInput()
161+
{
162+
Text = "I'd like to make an appointment for 12pm."
163+
}
164+
};
165+
_service.Message(OnMessage3, OnFail, _assistantId, _sessionId, messageRequest3);
166+
167+
while (!_messageTested3)
168+
{
169+
yield return null;
170+
}
171+
172+
Log.Debug("ExampleAssistantV2.RunTest()", "On Friday please.");
173+
MessageRequest messageRequest4 = new MessageRequest()
174+
{
175+
Input = new MessageInput()
176+
{
177+
Text = "On Friday please."
178+
}
179+
};
180+
_service.Message(OnMessage4, OnFail, _assistantId, _sessionId, messageRequest4);
181+
182+
while (!_messageTested4)
183+
{
184+
yield return null;
185+
}
186+
187+
Log.Debug("ExampleAssistantV2.RunTest()", "Attempting to delete session");
124188
_service.DeleteSession(OnDeleteSession, OnFail, _assistantId, _sessionId);
125189

126190
while (!_deleteSessionTested)
@@ -137,9 +201,34 @@ private void OnDeleteSession(object response, Dictionary<string, object> customD
137201
_createSessionTested = true;
138202
}
139203

140-
private void OnMessage(MessageResponse response, Dictionary<string, object> customData)
204+
private void OnMessage0(MessageResponse response, Dictionary<string, object> customData)
205+
{
206+
Log.Debug("ExampleAssistantV2.OnMessage0()", "response: {0}", response.Output.Generic[0].Text);
207+
_messageTested0 = true;
208+
}
209+
210+
private void OnMessage1(MessageResponse response, Dictionary<string, object> customData)
211+
{
212+
Log.Debug("ExampleAssistantV2.OnMessage1()", "response: {0}", response.Output.Generic[0].Text);
213+
214+
_messageTested1 = true;
215+
}
216+
217+
private void OnMessage2(MessageResponse response, Dictionary<string, object> customData)
218+
{
219+
Log.Debug("ExampleAssistantV2.OnMessage2()", "response: {0}", response.Output.Generic[0].Text);
220+
_messageTested2 = true;
221+
}
222+
223+
private void OnMessage3(MessageResponse response, Dictionary<string, object> customData)
224+
{
225+
Log.Debug("ExampleAssistantV2.OnMessage3()", "response: {0}", response.Output.Generic[0].Text);
226+
_messageTested3 = true;
227+
}
228+
private void OnMessage4(MessageResponse response, Dictionary<string, object> customData)
141229
{
142-
_messageTested = true;
230+
Log.Debug("ExampleAssistantV2.OnMessage4()", "response: {0}", response.Output.Generic[0].Text);
231+
_messageTested4 = true;
143232
}
144233

145234
private void OnCreateSession(SessionResponse response, Dictionary<string, object> customData)

Scripts/Services/Assistant/v2/Assistant.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using IBM.Watson.DeveloperCloud.Logging;
2121
using IBM.Watson.DeveloperCloud.Utilities;
2222
using IBM.WatsonDeveloperCloud.Assistant.v2;
23-
using MiniJSON;
2423
using System;
2524
using System.Collections.Generic;
2625
using System.Text;

Scripts/UnitTests/TestAssistantV2.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using IBM.Watson.DeveloperCloud.UnitTests;
2424
using IBM.Watson.DeveloperCloud.Utilities;
2525
using IBM.WatsonDeveloperCloud.Assistant.v2;
26-
using System;
2726
using System.Collections;
2827
using System.Collections.Generic;
2928
using System.IO;

0 commit comments

Comments
 (0)