@@ -76,13 +76,13 @@ To get started with the Watson Services in Unity, click on each service below to
76
76
Before you can use a service, it must be authenticated with the service instance's ` username ` , ` password ` and ` url ` .
77
77
78
78
``` cs
79
- using IBM .Watson .DeveloperCloud .Services .Conversation .v1 ;
79
+ using IBM .Watson .DeveloperCloud .Services .Assistant .v1 ;
80
80
using IBM .Watson .DeveloperCloud .Utilities ;
81
81
82
82
void Start ()
83
83
{
84
84
Credentials credentials = new Credentials (< username > , < password > , < url > );
85
- Conversation _conversation = new Conversation (credentials );
85
+ Assistant _assistant = new Assistant (credentials );
86
86
}
87
87
```
88
88
@@ -105,7 +105,7 @@ Success and failure callbacks are required. You can specify the return type in t
105
105
private void Example ()
106
106
{
107
107
// Call with sepcific callbacks
108
- conversation .Message (OnMessage , OnGetEnvironmentsFail , _workspaceId , " " );
108
+ assistant .Message (OnMessage , OnGetEnvironmentsFail , _workspaceId , " " );
109
109
discovery .GetEnvironments (OnGetEnvironments , OnFail );
110
110
}
111
111
@@ -139,7 +139,7 @@ Since the success callback signature is generic and the failure callback always
139
139
private void Example ()
140
140
{
141
141
// Call with generic callbacks
142
- conversation .Message (OnSuccess , OnMessageFail , " <workspace-id>" , " " );
142
+ assistant .Message (OnSuccess , OnMessageFail , " <workspace-id>" , " " );
143
143
discovery .GetEnvironments (OnSuccess , OnFail );
144
144
}
145
145
@@ -164,7 +164,7 @@ void Example()
164
164
{
165
165
Dictionary < string , object > customData = new Dictionary <string , object >();
166
166
customData .Add (" foo" , " bar" );
167
- conversation .Message (OnSuccess , OnFail , " <workspace-id>" , " " , customData );
167
+ assistant .Message (OnSuccess , OnFail , " <workspace-id>" , " " , customData );
168
168
}
169
169
170
170
// Generic success callback
@@ -181,13 +181,54 @@ private void OnFail(RESTConnector.Error error, Dictionary<string, object> custom
181
181
}
182
182
```
183
183
184
+ ## Custom Request Headers
185
+ You can send custom request headers by adding them to the ` customData ` object.
186
+
187
+ ``` cs
188
+ void Example ()
189
+ {
190
+ // Create customData object
191
+ Dictionary < string , object > customData = new Dictionary <string , object >();
192
+ // Create a dictionary of custom headers
193
+ Dictionary < string , string > customHeaders = new Dictionary <string , string >();
194
+ // Add to the header dictionary
195
+ customHeaders .Add (" X-Watson-Metadata" , " customer_id=some-assistant-customer-id" );
196
+ // Add the header dictionary to the custom data object
197
+ customData .Add (Constants .String .CUSTOM_REQUEST_HEADERS , customHeaders );
198
+
199
+ assistant .Message (OnSuccess , OnFail , " <workspace-id>" , customData : customData );
200
+ }
201
+ ```
202
+
203
+ ## Response Headers
204
+ You can get responseheaders in the ` customData ` object in the callback.
205
+
206
+ ``` cs
207
+ void Example ()
208
+ {
209
+ assistant .Message (OnMessage , OnFail , " <workspace-id>" );
210
+ }
211
+
212
+ private void OnMessage (object resp , Dictionary < string , object > customData )
213
+ {
214
+ // List all headers in the response headers object
215
+ if (customData .ContainsKey (Constants .String .RESPONSE_HEADERS ))
216
+ {
217
+ foreach (KeyValuePair < string , string > kvp in customData [Constants .String .RESPONSE_HEADERS ] as Dictionary <string , string >)
218
+ {
219
+ Log .Debug (" ExampleCustomHeader.OnMessage()" , " {0}: {1}" , kvp .Key , kvp .Value );
220
+ }
221
+ }
222
+ }
223
+ ```
224
+
184
225
## Authentication Tokens
185
226
You use tokens to write applications that make authenticated requests to IBM Watson™ services without embedding service credentials in every call.
186
227
187
228
You can write an authentication proxy in IBM Cloud that obtains and returns a token to your client application, which can then use the token to call the service directly. This proxy eliminates the need to channel all service requests through an intermediate server-side application, which is otherwise necessary to avoid exposing your service credentials from your client application.
188
229
189
230
``` cs
190
- using IBM .Watson .DeveloperCloud .Services .Conversation .v1 ;
231
+ using IBM .Watson .DeveloperCloud .Services .Assistant .v1 ;
191
232
using IBM .Watson .DeveloperCloud .Utilities ;
192
233
193
234
void Start ()
@@ -196,7 +237,7 @@ void Start()
196
237
{
197
238
AuthenticationToken = < authentication - token >
198
239
};
199
- Conversation _conversation = new Conversation (credentials );
240
+ Assistant _assistant = new Assistant (credentials );
200
241
}
201
242
```
202
243
0 commit comments