Introduction

IBM Watson™ Assistant for IBM Cloud Pak for Data combines machine learning, natural language understanding, and an integrated dialog editor to create conversation flows between your apps and your users.

This documentation describes Java SDK major version 9. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Node SDK major version 6. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Python SDK major version 5. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Ruby SDK major version 2. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes .NET Standard SDK major version 5. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Go SDK major version 2. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Swift SDK major version 4. For more information about how to update your code from the previous version, see the migration guide.

This documentation describes Unity SDK major version 5. For more information about how to update your code from the previous version, see the migration guide.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

If you need to change a skill programmatically (rather than by using the Watson Assistant user interface), you can use the workspace authoring methods that are provided by the v1 API.

The IBM Watson Unity SDK has the following requirements.

  • The SDK requires Unity version 2018.2 or later to support Transport Layer Security (TLS) 1.2.
    • Set the project settings for both the Scripting Runtime Version and the Api Compatibility Level to .NET 4.x Equivalent.
    • For more information, see TLS 1.0 support.
  • The SDK doesn't support the WebGL projects. Change your build settings to any platform except WebGL.

For more information about how to install and configure the SDK and SDK Core, see https://github.com/watson-developer-cloud/unity-sdk.

The code examples on this tab use the client library that is provided for Java.

Maven

<dependency>
  <groupId>com.ibm.watson</groupId>
  <artifactId>ibm-watson</artifactId>
  <version>9.0.2</version>
</dependency>

Gradle

compile 'com.ibm.watson:ibm-watson:9.0.2'

GitHub

The code examples on this tab use the client library that is provided for Node.js.

Installation

npm install ibm-watson@^6.0.2

GitHub

The code examples on this tab use the client library that is provided for Python.

Installation

pip install --upgrade "ibm-watson>=5.1.0"

GitHub

The code examples on this tab use the client library that is provided for Ruby.

Installation

gem install ibm_watson

GitHub

The code examples on this tab use the client library that is provided for Go.

go get -u github.com/watson-developer-cloud/go-sdk@v2.0.2

GitHub

The code examples on this tab use the client library that is provided for Swift.

Cocoapods

pod 'IBMWatsonAssistantV2', '~> 4.1.0'

Carthage

github "watson-developer-cloud/swift-sdk" ~> 4.1.0

Swift Package Manager

.package(url: "https://github.com/watson-developer-cloud/swift-sdk", from: "4.1.0")

GitHub

The code examples on this tab use the client library that is provided for .NET Standard.

Package Manager

Install-Package IBM.Watson.Assistant.v2 -Version 5.0.1

.NET CLI

dotnet add package IBM.Watson.Assistant.v2 --version 5.0.1

PackageReference

<PackageReference Include="IBM.Watson.Assistant.v2" Version="5.0.1" />

GitHub

The code examples on this tab use the client library that is provided for Unity.

GitHub

Authentication

For Cloud Pak for Data, you pass a bearer token in an Authorization header to authenticate to the API. The token is associated with a username.

  • For testing and development, you can use the bearer token that's displayed in the Cloud Pak for Data web client. To find this token, view the details for the provisioned service instance. The details also include the service endpoint URL. Don't use this token in production because it does not expire.
  • For production use, create a user in the Cloud Pak for Data web client to use for authentication. Generate a token from that user's credentials with the POST preauth/validateAuth method.

For Cloud Pak for Data instances, pass either username and password credentials or a bearer token that you generate to authenticate to the API. Username and password credentials use basic authentication. However, the SDK manages the lifecycle of the token. Tokens are temporary security credentials. If you pass a token, you maintain the token lifecycle.

For production use, create a user in the Cloud Pak for Data web client to use for authentication, and decide which authentication mechanism to use.

  • To have the SDK manage the lifecycle of the token, use the username and password for that new user in your calls.
  • To manage the lifecycle of the token yourself, generate a token from that user's credentials. Call the POST preauth/validateAuth method to generate the token, and then pass the token in an Authorization header in your calls. You can see an example of the method on the Curl tab.

Don't use the bearer token that's displayed in the web client for the instance except during testing and development because that token does not expire.

To find your value for {cpd_cluster_host}, {:port}, and {instance_id}, view the service credentials by viewing the details for the provisioned service instance in the Cloud Pak for Data web client.

Generating a bearer token. The response includes an accessToken property.

Replace {cpd_cluster_host} and {port} with the details for the service instance. Replace {username} and {password} with your Cloud Pak for Data credentials.

curl -k -u "{username}:{password}" "https://{cpd_cluster_host}{:port}/v1/preauth/validateAuth"

Authenticating to the API. Replace {accessToken} with your details.

curl -H "Authorization: Bearer {accessToken}" "{url}/v2/{method}"

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Assistant assistant = new Assistant("{version}", authenticator);
assistant.setServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

const AssistantV2 = require('ibm-watson/assistant/v2');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');

const assistant = new AssistantV2({
  version: '{version}',
  authenticator: new CloudPakForDataAuthenticator({
    username: '{username}',
    password: '{password}',
    url: 'https://{cpd_cluster_host}{:port}',
  }),
  serviceUrl: 'https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api',
});

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

from ibm_watson import AssistantV2
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator

authenticator = CloudPakForDataAuthenticator(
    '{username}',
    '{password}',
    'https://{cpd_cluster_host}{:port}'
)

assistant = AssistantV2(
    version='{version}',
    authenticator=authenticator
)

assistant.set_service_url('https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api')

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

require "ibm_watson/authenticators"
require "ibm_watson/assistant_v2"
include IBMWatson

authenticator = Authenticators::CloudPakForDataAuthenticator.new(
  username: "{username}",
  password: "{password}",
  url: "https://{cpd_cluster_host}{:port}"
)
assistant = AssistantV2.new(
  version: "{version}",
  authenticator: authenticator
)
assistant.service_url = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

import (
  "github.com/IBM/go-sdk-core/core"
  "github.com/watson-developer-cloud/go-sdk/assistantv2"
)

func main() {
  authenticator := &core.CloudPakForDataAuthenticator{
    URL: "https://{cpd_cluster_host}{:port}",
    Username: "{username}",
    Password: "{password}",
  }

  options := &assistantv2.AssistantV2Options{
    Version: "{version}",
    Authenticator: authenticator,
  }

  assistant, assistantErr := assistantv2.NewAssistantV2(options)

  if assistantErr != nil {
    panic(assistantErr)
  }

  assistant.SetServiceURL("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api")
}

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let assistant = Assistant(version: "{version}", authenticator: authenticator)
assistant.serviceURL = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
    );

AssistantService assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

SDK managing the token.

Replace {username} and {password} with your Cloud Pak for Data credentials. Replace {version} with the service version date. For {cpd_cluster_host}, {port}, {release}, and {instance_id}, see Endpoint URLs.

var authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

Endpoint URLs

For services installed on Cloud Pak for Data, the base URLs come from the cluster and add-on service instance. The URL follows this pattern:

https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api
  • {cpd_cluster_host} represents the name or IP address of your deployed cluster. For Cloud Pak for Data System, use a hostname that resolves to an IP address in the cluster.
  • {port} represents the port number on which the service listens.
  • {release} represents the release name that was specified when the Helm chart was installed.
  • {instance_id} represents the identifier of the service instance.

To find the base URL, view the details for the service instance from the Cloud Pak for Data web client.

Use that URL in your requests to Watson Assistant for IBM Cloud Pak for Data v2 API.

Set the URL by calling the setServiceUrl() method of the service instance.

Set the correct service URL by specifying the serviceUrl parameter when you create the service instance.

Set the correct service URL by specifying the url parameter when you create the service instance or by calling the set_url() method of the service instance.

Set the correct service URL by specifying the url parameter when you create the service instance or by calling the url= method of the service instance.

Set the correct service URL by specifying the URL parameter when you create the service instance or by calling the SetURL= method of the service instance.

Set the correct service URL by setting the serviceURL property of the service instance.

Set the correct service URL by calling the SetEndpoint() method of the service instance.

Set the correct service URL by setting the Url property of the service instance.

Endpoint example

curl -X {request_method} -H "Authorization: Bearer {token}" "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api/v2/{method}"

Endpoint example

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Assistant assistant = new Assistant("{version}", authenticator);
assistant.setServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

Endpoint example

const AssistantV2 = require('ibm-watson/assistant/v2');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');

const assistant = new AssistantV2({
  version: '{version}',
  authenticator: new CloudPakForDataAuthenticator({
    username: '{username}',
    password: '{password}',
    url: 'https://{cpd_cluster_host}{:port}',
  }),
  serviceUrl: 'https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api',
});

Endpoint example

from ibm_watson import AssistantV2
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator

authenticator = CloudPakForDataAuthenticator(
    '{username}',
    '{password}',
    'https://{cpd_cluster_host}{:port}'
)

assistant = AssistantV2(
    version='{version}',
    authenticator=authenticator
)

assistant.set_service_url('https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api')

Endpoint example

require "ibm_watson/authenticators"
require "ibm_watson/assistant_v2"
include IBMWatson

authenticator = Authenticators::CLoudPakForDataAuthenticator.new(
  username: "{username}",
  password: "{password}",
  url: "https://{cpd_cluster_host}{:port}"
)
assistant = AssistantV2.new(
  version: "{version}",
  authenticator: authenticator
)
assistant.service_url = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

Endpoint example

assistant, assistantErr := assistantv2.NewAssistantV2(options)

if assistantErr != nil {
  panic(assistantErr)
}

assistant.SetServiceURL("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api")

Endpoint example

let authenticator = CloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let assistant = Assistant(version: "{version}", authenticator: authenticator)
assistant.serviceURL = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

Endpoint example

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
    );

AssistantService assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

Endpoint example

var authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

Disabling SSL verification

All Watson services use Secure Sockets Layer (SSL) (or Transport Layer Security (TLS)) for secure connections between the client and server. The connection is verified against the local certificate store to ensure authentication, integrity, and confidentiality.

If you use a self-signed certificate, you need to disable SSL verification to make a successful connection.

Enabling SSL verification is highly recommended. Disabling SSL jeopardizes the security of the connection and data. Disable SSL only if necessary, and take steps to enable SSL as soon as possible.

To disable SSL verification for a curl request, use the --insecure (-k) option with the request.

To disable SSL verification, create an HttpConfigOptions object and set the disableSslVerification property to true. Then, pass the object to the service instance by using the configureClient method.

To disable SSL verification, set the disableSslVerification parameter to true when you create the service instance.

To disable SSL verification, specify True on the set_disable_ssl_verification method for the service instance.

To disable SSL verification, set the disable_ssl_verification parameter to true in the configure_http_client() method for the service instance.

To disable SSL verification, call the DisableSSLVerification method on the service instance.

To disable SSL verification, call the disableSSLVerification() method on the service instance. You cannot disable SSL verification on Linux.

To disable SSL verification, set the DisableSslVerification method to true on the service instance.

To disable SSL verification, set the DisableSslVerification method to true on the service instance.

Example to disable SSL verification

curl -k -X {request_method} -H "Authorization: Bearer {token}" "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api/v2/{method}"

Example to disable SSL verification

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
Assistant assistant = new Assistant("{version}", authenticator);
assistant.setServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api";

HttpConfigOptions configOptions = new HttpConfigOptions.Builder()
  .disableSslVerification(true)
  .build();
assistant.configureClient(configOptions);

Example to disable SSL verification

const AssistantV2 = require('ibm-watson/assistant/v2');
const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');

const assistant = new AssistantV2({
  version: '{version}',
  authenticator: new CloudPakForDataAuthenticator({
    username: '{username}',
    password: '{password}',
    url: 'https://{cpd_cluster_host}{:port}',
  }),
  serviceUrl: 'https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api',
  disableSslVerification: true,
});

Example to disable SSL verification

from ibm_watson import AssistantV2
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator

authenticator = CloudPakForDataAuthenticator(
    '{username}',
    '{password}'
)

assistant = AssistantV2(
    version='{version}',
    authenticator=authenticator
)

assistant.set_service_url('https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api')

assistant.set_disable_ssl_verification(True)

Example to disable SSL verification

require "ibm_watson/authenticators"
require "ibm_watson/assistant_v2"
include IBMWatson

authenticator = Authenticators::CLoudPakForDataAuthenticator.new(
  username: "{username}",
  password: "{password}",
  url: "https://{cpd_cluster_host}{:port}"
)
assistant = AssistantV2.new(
  version: "{version}",
  authenticator: authenticator
)
assistant.service_url = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

assistant.configure_http_client(disable_ssl_verification: true)

Example to disable SSL verification

assistant, assistantErr := assistantv2.NewAssistantV2(options)

if assistantErr != nil {
  panic(assistantErr)
}

assistant.SetServiceURL("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api")

assistant.DisableSSLVerification()

Example to disable SSL verification

let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
let assistant = Assistant(version: "{version}", authenticator: authenticator)
assistant.serviceURL = "https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api"

assistant.disableSSLVerification()

Example to disable SSL verification

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
    );

AssistantService assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

assistant.DisableSslVerification(true);

Example to disable SSL verification

var authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

assistant.DisableSslVerification = true;

Versioning

API requests require a version parameter that takes a date in the format version=YYYY-MM-DD. When we change the API in a backwards-incompatible way, we release a new version date.

Send the version parameter with every API request. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

Specify the version to use on API requests with the version parameter when you create the service instance. The service uses the API version for the date you specify, or the most recent version before that date. Don't default to the current date. Instead, specify a date that matches a version that is compatible with your app, and don't change it until your app is ready for a later version.

This documentation describes the current version of Watson Assistant, 2020-09-24. In some cases, differences in earlier versions are noted in the descriptions of parameters and response models.

Error handling

Watson Assistant uses standard HTTP response codes to indicate whether a method completed successfully. HTTP response codes in the 2xx range indicate success. A response in the 4xx range is some sort of failure, and a response in the 5xx range usually indicates an internal system error that cannot be resolved by the user. Response codes are listed with the method.

ErrorResponse

Name Description
code
integer
The HTTP response code.
error
string
General description of an error.
errors
ErrorDetail[]
Collection of specific constraint violations associated with the error.

ErrorDetail

Name Description
message
string
Description of a specific constraint violation.
path
string
The location of the constraint violation.

The Java SDK generates an exception for any unsuccessful method invocation. All methods that accept an argument can also throw an IllegalArgumentException.

Exception Description
IllegalArgumentException An invalid argument was passed to the method.

When the Java SDK receives an error response from the Watson Assistant service, it generates an exception from the com.ibm.watson.developer_cloud.service.exception package. All service exceptions contain the following fields.

Field Description
statusCode The HTTP response code that is returned.
message A message that describes the error.

When the Node SDK receives an error response from the Watson Assistant service, it creates an Error object with information that describes the error that occurred. This error object is passed as the first parameter to the callback function for the method. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Python SDK generates an exception for any unsuccessful method invocation. When the Python SDK receives an error response from the Watson Assistant service, it generates an ApiException with the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

When the Ruby SDK receives an error response from the Watson Assistant service, it generates an ApiException with the following fields.

Field Description
code The HTTP response code that is returned.
message A message that describes the error.
info A dictionary of additional information about the error.

The Go SDK generates an error for any unsuccessful service instantiation and method invocation. You can check for the error immediately. The contents of the error object are as shown in the following table.

Error

Field Description
code The HTTP response code that is returned.
message A message that describes the error.

The Swift SDK returns a WatsonError in the completionHandler any unsuccessful method invocation. This error type is an enum that conforms to LocalizedError and contains an errorDescription property that returns an error message. Some of the WatsonError cases contain associated values that reveal more information about the error.

Field Description
errorDescription A message that describes the error.

When the .NET Standard SDK receives an error response from the Watson Assistant service, it generates a ServiceResponseException with the following fields.

Field Description
Message A message that describes the error.
CodeDescription The HTTP response code that is returned.

When the Unity SDK receives an error response from the Watson Assistant service, it generates an IBMError with the following fields.

Field Description
Url The URL that generated the error.
StatusCode The HTTP response code returned.
ErrorMessage A message that describes the error.
Response The contents of the response from the server.
ResponseHeaders A dictionary of headers returned by the request.

Example error handling

try {
  // Invoke a method
} catch (NotFoundException e) {
  // Handle Not Found (404) exception
} catch (RequestTooLargeException e) {
  // Handle Request Too Large (413) exception
} catch (ServiceResponseException e) {
  // Base class for all exceptions caused by error responses from the service
  System.out.println("Service returned status code "
    + e.getStatusCode() + ": " + e.getMessage());
}

Example error handling

assistant.method(params)
  .catch(err => {
    console.log('error:', err);
  });

Example error handling

from ibm_watson import ApiException
try:
    # Invoke a method
except ApiException as ex:
    print "Method failed with status code " + str(ex.code) + ": " + ex.message

Example error handling

require "ibm_watson"
begin
  # Invoke a method
rescue IBMWatson::ApiException => ex
  print "Method failed with status code #{ex.code}: #{ex.error}"
end

Example error handling

import "github.com/watson-developer-cloud/go-sdk/assistantv2"

// Instantiate a service
assistant, assistantErr := assistantv2.NewAssistantV2(options)

// Check for errors
if assistantErr != nil {
  panic(assistantErr)
}

// Call a method
result, response, responseErr := assistant.MethodName(&methodOptions)

// Check for errors
if responseErr != nil {
  panic(responseErr)
}

Example error handling

assistant.method() {
  response, error in

  if let error = error {
    switch error {
    case let .http(statusCode, message, metadata):
      switch statusCode {
      case .some(404):
        // Handle Not Found (404) exception
        print("Not found")
      case .some(413):
        // Handle Request Too Large (413) exception
        print("Payload too large")
      default:
        if let statusCode = statusCode {
          print("Error - code: \(statusCode), \(message ?? "")")
        }
      }
    default:
      print(error.localizedDescription)
    }
    return
  }

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }

  print(result)
}

Example error handling

try
{
    // Invoke a method
}
catch(ServiceResponseException e)
{
    Console.WriteLine("Error: " + e.Message);
}
catch (Exception e)
{
    Console.WriteLine("Error: " + e.Message);
}

Example error handling

// Invoke a method
assistant.MethodName(Callback, Parameters);

// Check for errors
private void Callback(DetailedResponse<ExampleResponse> response, IBMError error)
{
    if (error == null)
    {
        Log.Debug("ExampleCallback", "Response received: {0}", response.Response);
    }
    else
    {
        Log.Debug("ExampleCallback", "Error received: {0}, {1}, {3}", error.StatusCode, error.ErrorMessage, error.Response);
    }
}

Data handling

Additional headers

Some Watson services accept special parameters in headers that are passed with the request.

You can pass request header parameters in all requests or in a single request to the service.

To pass a request header, use the --header (-H) option with a curl request.

To pass header parameters with every request, use the setDefaultHeaders method of the service object.

To pass header parameters in a single request, use the addHeader method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the headers parameter when you create the service object.

To pass header parameters in a single request, use the headers method as a modifier on the request before you execute it.

To pass header parameters with every request, specify the set_default_headers method of the service object.

To pass header parameters in a single request, include headers as a dict in the request.

To pass header parameters with every request, specify the add_default_headers method of the service object.

To pass header parameters in a single request, specify the headers method as a chainable method in the request.

To pass header parameters with every request, specify the SetDefaultHeaders method of the service object.

To pass header parameters in a single request, specify the Headers as a map in the request.

To pass header parameters with every request, add them to the defaultHeaders property of the service object.

To pass header parameters in a single request, pass the headers parameter to the request method.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

To pass header parameters in a single request, use the WithHeader() method as a modifier on the request before you execute it.

Example header parameter in a request

curl -X {request_method} -H "Request-Header: {header_value}" "{url}/v2/{method}"

Example header parameter in a request

ReturnType returnValue = assistant.methodName(parameters)
  .addHeader("Custom-Header", "{header_value}")
  .execute();

Example header parameter in a request

const parameters = {
  {parameters}
};

assistant.methodName(
  parameters,
  headers: {
    'Custom-Header': '{header_value}'
  })
   .then(result => {
    console.log(response);
  })
  .catch(err => {
    console.log('error:', err);
  });

Example header parameter in a request

response = assistant.methodName(
    parameters,
    headers = {
        'Custom-Header': '{header_value}'
    })

Example header parameter in a request

response = assistant.headers(
  "Custom-Header" => "{header_value}"
).methodName(parameters)

Example header parameter in a request

result, response, responseErr := assistant.MethodName(
  &methodOptions{
    Headers: map[string]string{
      "Accept": "application/json",
    },
  },
)

Example header parameter in a request

let customHeader: [String: String] = ["Custom-Header": "{header_value}"]
assistant.methodName(parameters, headers: customHeader) {
  response, error in
}

Example header parameter in a request

CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
    );

AssistantService assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

assistant.WithHeader("Custom-Header", "header_value");

Example header parameter in a request

var authenticator = new CloudPakForDataAuthenticator(
    url: "https://{cpd_cluster_host}{:port}",
    username: "{username}",
    password: "{password}"
);

while (!authenticator.CanAuthenticate())
    yield return null;

var assistant = new AssistantService("{version}", authenticator);
assistant.SetServiceUrl("https://{cpd_cluster_host}{:port}/assistant/{release}/instances/{instance_id}/api");

assistant.WithHeader("Custom-Header", "header_value");

Response details

The Watson Assistant service might return information to the application in response headers.

To access all response headers that the service returns, include the --include (-i) option with a curl request. To see detailed response data for the request, including request headers, response headers, and extra debugging information, include the --verbose (-v) option with the request.

Example request to access response headers

curl -X {request_method} {authentication_method} --include "{url}/v2/{method}"

To access information in the response headers, use one of the request methods that returns details with the response: executeWithDetails(), enqueueWithDetails(), or rxWithDetails(). These methods return a Response<T> object, where T is the expected response model. Use the getResult() method to access the response object for the method, and use the getHeaders() method to access information in response headers.

Example request to access response headers

Response<ReturnType> response = assistant.methodName(parameters)
  .executeWithDetails();
// Access response from methodName
ReturnType returnValue = response.getResult();
// Access information in response headers
Headers responseHeaders = response.getHeaders();

All response data is available in the Response<T> object that is returned by each method. To access information in the response object, use the following properties.

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

assistant.methodName(parameters)
  .then(response => {
    console.log(response.headers);
  })
  .catch(err => {
    console.log('error:', err);
  });

The return value from all service methods is a DetailedResponse object. To access information in the result object or response headers, use the following methods.

DetailedResponse

Method Description
get_result() Returns the response for the service-specific method.
get_headers() Returns the response header information.
get_status_code() Returns the HTTP status code.

Example request to access response headers

assistant.set_detailed_response(True)
response = assistant.methodName(parameters)
# Access response from methodName
print(json.dumps(response.get_result(), indent=2))
# Access information in response headers
print(response.get_headers())
# Access HTTP response status
print(response.get_status_code())

The return value from all service methods is a DetailedResponse object. To access information in the response object, use the following properties.

DetailedResponse

Property Description
result Returns the response for the service-specific method.
headers Returns the response header information.
status Returns the HTTP status code.

Example request to access response headers

response = assistant.methodName(parameters)
# Access response from methodName
print response.result
# Access information in response headers
print response.headers
# Access HTTP response status
print response.status

The return value from all service methods is a DetailedResponse object. To access information in the response object or response headers, use the following methods.

DetailedResponse

Method Description
GetResult() Returns the response for the service-specific method.
GetHeaders() Returns the response header information.
GetStatusCode() Returns the HTTP status code.

Example request to access response headers

import (
  "github.com/IBM/go-sdk-core/core"
  "github.com/watson-developer-cloud/go-sdk/assistantv2"
)
result, response, responseErr := assistant.MethodName(
  &methodOptions{})
// Access result
core.PrettyPrint(response.GetResult(), "Result ")

// Access response headers
core.PrettyPrint(response.GetHeaders(), "Headers ")

// Access status code
core.PrettyPrint(response.GetStatusCode(), "Status Code ")

All response data is available in the WatsonResponse<T> object that is returned in each method's completionHandler.

Example request to access response headers

assistant.methodName(parameters) {
  response, error in

  guard let result = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }
  print(result) // The data returned by the service
  print(response?.statusCode)
  print(response?.headers)
}

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

var results = assistant.MethodName(parameters);

var result = results.Result;            //  The result object
var responseHeaders = results.Headers;  //  The response headers
var responseJson = results.Response;    //  The raw response JSON
var statusCode = results.StatusCode;    //  The response status code

The response contains fields for response headers, response JSON, and the status code.

DetailedResponse

Property Description
Result Returns the result for the service-specific method.
Response Returns the raw JSON response for the service-specific method.
Headers Returns the response header information.
StatusCode Returns the HTTP status code.

Example request to access response headers

private void Example()
{
    assistant.MethodName(Callback, Parameters);
}

private void Callback(DetailedResponse<ResponseType> response, IBMError error)
{
    var result = response.Result;                 //  The result object
    var responseHeaders = response.Headers;       //  The response headers
    var responseJson = reresponsesults.Response;  //  The raw response JSON
    var statusCode = response.StatusCode;         //  The response status code
}

Data labels

You can remove customer data if you associate the customer and the data when you send the information to a service. First, you label the data with a customer ID, and then you can delete the data by the ID.

  • Use the X-Watson-Metadata header to associate a customer ID with the data. By adding a customer ID to a request, you indicate that it contains data that belongs to that customer.

    Specify a random or generic string for the customer ID. Do not include personal data, such as an email address. Pass the string customer_id={id} as the argument of the header.

  • Use the Delete labeled data method to remove data that is associated with a customer ID.

Labeling data is used only by methods that accept customer data. For more information about Watson Assistant and labeling data, see Information security.

For more information about how to pass headers, see Additional headers.

Synchronous and asynchronous requests

The Java SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the ServiceCall interface.

  • To call a method synchronously, use the execute method of the ServiceCall interface. You can call the execute method directly from an instance of the service.
  • To call a method asynchronously, use the enqueue method of the ServiceCall interface to receive a callback when the response arrives. The ServiceCallback interface of the method's argument provides onResponse and onFailure methods that you override to handle the callback.

The Ruby SDK supports both synchronous (blocking) and asynchronous (non-blocking) execution of service methods. All service methods implement the Concurrent::Async module. When you use the synchronous or asynchronous methods, an IVar object is returned. You access the DetailedResponse object by calling ivar_object.value.

For more information about the Ivar object, see the IVar class docs.

  • To call a method synchronously, either call the method directly or use the .await chainable method of the Concurrent::Async module.

    Calling a method directly (without .await) returns a DetailedResponse object.

  • To call a method asynchronously, use the .async chainable method of the Concurrent::Async module.

You can call the .await and .async methods directly from an instance of the service.

Example synchronous request

ReturnType returnValue = assistant.method(parameters).execute();

Example asynchronous request

assistant.method(parameters).enqueue(new ServiceCallback<ReturnType>() {
  @Override public void onResponse(ReturnType response) {
    . . .
  }
  @Override public void onFailure(Exception e) {
    . . .
  }
});

Example synchronous request

response = assistant.method_name(parameters)

or

response = assistant.await.method_name(parameters)

Example asynchronous request

response = assistant.async.method_name(parameters)

Methods

Create a session

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the documentation.

POST /v2/assistants/{assistant_id}/sessions
ServiceCall<SessionResponse> createSession(CreateSessionOptions createSessionOptions)
createSession(params)
create_session(self,
        assistant_id: str,
        version: str,
        **kwargs
    ) -> DetailedResponse
create_session(assistant_id:, version:)
(assistant *AssistantV2) CreateSession(createSessionOptions *CreateSessionOptions) (result *SessionResponse, response *core.DetailedResponse, err error)
(assistant *AssistantV2) CreateSessionWithContext(ctx context.Context, createSessionOptions *CreateSessionOptions) (result *SessionResponse, response *core.DetailedResponse, err error)
CreateSession(string assistantId, string version)
CreateSession(Callback<SessionResponse> callback, string assistantId, string version)
func createSession(
    assistantID: String,
    version: String,
    headers: [String: String]? = nil,
    completionHandler: @escaping (RestResponse<SessionResponse>?, RestError?) -> Void)

Request

Use the CreateSessionOptions.Builder to create a CreateSessionOptions object that contains the parameter values for the createSession method.

Instantiate the CreateSessionOptions struct and set the fields to provide parameter values for the CreateSession method.

Path Parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

Query Parameters

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

The createSession options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

WithContext method only

The CreateSession options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • curl -H "Authorization: Bearer {token}" -X POST "{url}/v2/assistants/{assistant_id}/sessions?version=2020-04-01"
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
        );
    
    AssistantService assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    var result = assistant.CreateSession(
        assistantId: "{assistantId}"
        );
    
    Console.WriteLine(result.Response);
    
    sessionId = result.Result.SessionId;
  • package main
    
    import (
      "encoding/json"
      "fmt"
      "github.com/IBM/go-sdk-core/core"
      "github.com/watson-developer-cloud/go-sdk/assistantv2"
    )
    
    func main() {
      authenticator := &core.CloudPakForDataAuthenticator{
        URL: "https://{cpd_cluster_host}{:port}",
        Username: "{username}", 
        Password: "{password}",
      }
    
      options := &assistantv2.AssistantV2Options{
        Version: "2020-04-01",
        Authenticator: authenticator,
      }
    
      assistant, assistantErr := assistantv2.NewAssistantV2(options)
    
      if assistantErr != nil {
        panic(assistantErr)
      }
    
      assistant.SetServiceURL("{url}")
    
      result, response, responseErr := assistant.CreateSession(assistant.
        NewCreateSessionOptions("{assistant_id}"))
      if responseErr != nil {
        panic(responseErr)
      }
      b, _ := json.MarshalIndent(result, "", "  ")
      fmt.Println(string(b))
    }
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
    Assistant assistant = new Assistant("2020-04-01", authenticator);
    assistant.setServiceUrl("{url}");
    
    CreateSessionOptions options = new CreateSessionOptions.Builder("{assistant_id}").build();
    
    SessionResponse response = assistant.createSession(options).execute().getResult();
    
    System.out.println(response);
  • const AssistantV2 = require('ibm-watson/assistant/v2');
    const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
    
    const assistant = new AssistantV2({
      version: '2020-04-01',
      authenticator: new CloudPakForDataAuthenticator({
        username: '{username}',
        password: '{password}',
        url: 'https://{cpd_cluster_host}{:port}',
      }),
      serviceUrl: '{url}',
    });
    
    assistant.createSession({
      assistantId: '{assistant_id}'
    })
      .then(res => {
        console.log(JSON.stringify(res.result, null, 2));
      })
      .catch(err => {
        console.log(err);
      });
  • import json
    from ibm_watson import AssistantV2
    from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
    
    authenticator = CloudPakForDataAuthenticator(
        '{username}',
        '{password}',
        'https://{cpd_cluster_host}{:port}'
    )
    assistant = AssistantV2(
        version='2020-04-01',
        authenticator = authenticator
    )
    
    assistant.set_service_url('{url}')
    
    response = assistant.create_session(
        assistant_id='{assistant_id}'
    ).get_result()
    
    print(json.dumps(response, indent=2))
  • require "json"
    require "ibm_watson/authenticators"
    require "ibm_watson/assistant_v2"
    include IBMWatson
    
    authenticator = Authenticators::CloudPakForDataAuthenticator.new(
      username: "{username}",
      password: "{password}",
      url: "https://{cpd_cluster_host}{:port}"
    )
    
    assistant = AssistantV2.new(
      version: "2020-04-01",
      authenticator: authenticator
    )
    assistant.service_url = "{url}"
    
    response = assistant.create_session(
      assistant_id: "{assistant_id}"
    )
    
    puts JSON.pretty_generate(response.result)
  • let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
    let assistant = Assistant(version: "2020-04-01", authenticator: authenticator)
    assistant.serviceURL = "{url}"
    
    assistant.createSession(assistantID: "{assistant_id}") {
      response, error in
    
      guard let session = response?.result else {
        print(error?.localizedDescription ?? "unknown error")
        return
      }
    
      sessionID = session.sessionID
      print(session)
    }
  • var authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
    );
    
    while (!authenticator.CanAuthenticate())
        yield return null;
    
    var assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    SessionResponse createSessionResponse = null;
    assistant.CreateSession(
        callback: (DetailedResponse<SessionResponse> response, IBMError error) =>
        {
            Log.Debug("AssistantV2", "result: {0}", response.Response);
            createSessionResponse = response.Result;
        },
        assistantId: "{assistantId}"
    );
    
    while (createSessionResponse == null)
        yield return null;

Response

Status Code

  • Successful request.

  • Invalid request.

Example responses
  • {
      "session_id": "af11c111-860d-4071-b6d2-550bf20c016e"
    }
  • {
      "session_id": "af11c111-860d-4071-b6d2-550bf20c016e"
    }

Delete session

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the documentation).

DELETE /v2/assistants/{assistant_id}/sessions/{session_id}
ServiceCall<Void> deleteSession(DeleteSessionOptions deleteSessionOptions)
deleteSession(params)
delete_session(self,
        assistant_id: str,
        version: str,
        session_id: str,
        **kwargs
    ) -> DetailedResponse
delete_session(assistant_id:, version:, session_id:)
(assistant *AssistantV2) DeleteSession(deleteSessionOptions *DeleteSessionOptions) (response *core.DetailedResponse, err error)
(assistant *AssistantV2) DeleteSessionWithContext(ctx context.Context, deleteSessionOptions *DeleteSessionOptions) (response *core.DetailedResponse, err error)
DeleteSession(string assistantId, string version, string sessionId)
DeleteSession(Callback<object> callback, string assistantId, string version, string sessionId)
func deleteSession(
    assistantID: String,
    version: String,
    sessionID: String,
    headers: [String: String]? = nil,
    completionHandler: @escaping (RestResponse<Void>?, RestError?) -> Void)

Request

Use the DeleteSessionOptions.Builder to create a DeleteSessionOptions object that contains the parameter values for the deleteSession method.

Instantiate the DeleteSessionOptions struct and set the fields to provide parameter values for the DeleteSession method.

Path Parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

Query Parameters

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

The deleteSession options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

WithContext method only

The DeleteSession options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • Unique identifier of the session.

  • curl -H "Authorization: Bearer {token}" -X DELETE "{url}/v2/assistants/{assistant_id}/sessions/{session_id}?version=2020-04-01"
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
        );
    
    AssistantService assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    var result = assistant.DeleteSession(
        assistantId: "{assistantId}",
        sessionId: "{sessionId}"
        );
    
    Console.WriteLine(result.Response);
  • package main
    
    import (
      "github.com/IBM/go-sdk-core/core"
      "github.com/watson-developer-cloud/go-sdk/assistantv2"
    )
    
    func main() {
      authenticator := &core.CloudPakForDataAuthenticator{
        URL: "https://{cpd_cluster_host}{:port}",
        Username: "{username}", 
        Password: "{password}",
      }
    
      options := &assistantv2.AssistantV2Options{
        Version: "2020-04-01",
        Authenticator: authenticator,
      }
    
      assistant, assistantErr := assistantv2.NewAssistantV2(options)
    
      if assistantErr != nil {
        panic(assistantErr)
      }
    
      assistant.SetServiceURL("{url}")
    
      _, responseErr := assistant.DeleteSession(assistant.
        NewDeleteSessionOptions("{assistant_id}", "{session_id}"))
      if responseErr != nil {
        panic(responseErr)
      }
    }
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
    Assistant assistant = new Assistant("2020-04-01", authenticator);
    assistant.setServiceUrl("{url}");
    
    DeleteSessionOptions options = new DeleteSessionOptions.Builder("{assistant_id}", "{session_id}").build();
    
    assistant.deleteSession(options).execute();
  • const AssistantV2 = require('ibm-watson/assistant/v2');
    const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
    
    const assistant = new AssistantV2({
      version: '2020-04-01',
      authenticator: new CloudPakForDataAuthenticator({
        username: '{username}',
        password: '{password}',
        url: 'https://{cpd_cluster_host}{:port}',
      }),
      serviceUrl: '{url}',
    });
    
    assistant.deleteSession({
      assistantId: '{assistant_id}',
      sessionId: '{session_id}',
    })
      .then(res => {
        console.log(JSON.stringify(res.result, null, 2));
      })
      .catch(err => {
        console.log(err);
      });
  • import json
    from ibm_watson import AssistantV2
    from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
    
    authenticator = CloudPakForDataAuthenticator(
        '{username}',
        '{password}',
        'https://{cpd_cluster_host}{:port}'
    )
    assistant = AssistantV2(
        version='2020-04-01',
        authenticator = authenticator
    )
    
    assistant.set_service_url('{url}')
    
    response = assistant.delete_session(
        assistant_id='{assistant_id}',
        session_id='{session_id}'
    ).get_result()
    
    print(json.dumps(response, indent=2))
  • require "json"
    require "ibm_watson/authenticators"
    require "ibm_watson/assistant_v2"
    include IBMWatson
    
    authenticator = Authenticators::CloudPakForDataAuthenticator.new(
      username: "{username}",
      password: "{password}",
      url: "https://{cpd_cluster_host}{:port}"
    )
    
    assistant = AssistantV2.new(
      version: "2020-04-01",
      authenticator: authenticator
    )
    assistant.service_url = "{url}"
    
    response = assistant.delete_session(
      assistant_id: "{assistant_id}",
      session_id: "{session_id}"
    )
  • let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
    let assistant = Assistant(version: "2020-04-01", authenticator: authenticator)
    assistant.serviceURL = "{url}"
    
    assistant.deleteSession(assistantID: "{assistant_id}", sessionID: "{session_id}") {
      _, error in
    
      if let error = error {
        print(error.localizedDescription)
        return
      }
    
      print("session deleted")
    }
  • var authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
    );
    
    while (!authenticator.CanAuthenticate())
        yield return null;
    
    var assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    assistant.DeleteSession(
        callback: (DetailedResponse<object> response, IBMError error) =>
        {
            Log.Debug("AssistantV2", "result: {0}", response.Response);
            deleteSessionResponse = response.Result;
        },
        assistantId: "{assistantId}",
        sessionId: "{sessionId}"
    );

Response

Response type: object

Response type: object

Status Code

  • Successful request.

  • Invalid request.

No Sample Response

This method does not specify any sample responses.

Send user input to assistant (stateful)

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

Send user input to an assistant and receive a response, with conversation state (including context data) stored by Watson Assistant for the duration of the session.

POST /v2/assistants/{assistant_id}/sessions/{session_id}/message
ServiceCall<MessageResponse> message(MessageOptions messageOptions)
message(params)
message(self,
        assistant_id: str,
        session_id: str,
        version: str,
        *,
        input: 'MessageInput' = None,
        context: 'MessageContext' = None,
        **kwargs
    ) -> DetailedResponse
message(assistant_id:, session_id:, version:, input: nil, context: nil)
(assistant *AssistantV2) Message(messageOptions *MessageOptions) (result *MessageResponse, response *core.DetailedResponse, err error)
(assistant *AssistantV2) MessageWithContext(ctx context.Context, messageOptions *MessageOptions) (result *MessageResponse, response *core.DetailedResponse, err error)
Message(string assistantId, string sessionId, string version, MessageInput input = null, MessageContext context = null)
Message(Callback<MessageResponse> callback, string assistantId, string sessionId, string version, MessageInput input = null, MessageContext context = null)
func message(
    assistantID: String,
    sessionID: String,
    version: String,
    input: MessageInput? = nil,
    context: MessageContext? = nil,
    headers: [String: String]? = nil,
    completionHandler: @escaping (RestResponse<MessageResponse>?, RestError?) -> Void)

Request

Use the MessageOptions.Builder to create a MessageOptions object that contains the parameter values for the message method.

Instantiate the MessageOptions struct and set the fields to provide parameter values for the Message method.

Path Parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

Query Parameters

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

The message to be sent. This includes the user's input, along with optional content such as intents and entities.

Example:

The message options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

WithContext method only

The Message options.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

parameters

  • Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the documentation.

    Note: Currently, the v2 API does not support creating assistants.

  • Unique identifier of the session.

  • Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The current version is 2020-04-01.

  • An input object that includes the input text.

  • curl -H "Authorization: Bearer {token}" -X POST -H "Content-Type:application/json" -d "{\"input\": {\"text\": \"Hello\"}}" "{url}/v2/assistants/{assistant_id}/sessions/{session_id}/message?version=2020-04-01"
  • curl -H "Authorization: Bearer {token}" -X POST -H "Content-Type: application/json" -d "{\"input\": {\"text\": \"Hello\", \"options\": {\"return_context\": true}}, \"context\": {\"global\": {\"system\": {\"user_id\": \"my_user_id\"}}, \"skills\": {\"main skill\": {\"user_defined\": {\"account_number\": \"123456\"}}}}}" "{url}/v2/assistants/{assistant_id}/sessions/{session_id}/message?version=2020-04-01"
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
        );
    
    AssistantService assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    var result = assistant.Message(
        assistantId: "{assistantId}",
        sessionId: "{sessionId}",
        input: new MessageInput()
        {
            Text = "Hello"
        }
        );
    
    Console.WriteLine(result.Response);
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
        );
    
    AssistantService assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    MessageContextSkills skills = new MessageContextSkills();
    MessageContextSkill skill = new MessageContextSkill();
    Dictionary<string, object> userDefinedDictionary = new Dictionary<string, object>();
    
    userDefinedDictionary.Add("account_number", "123456");
    skill.UserDefined = userDefinedDictionary;
    skills.Add("main skill", skill);
    
    var result = assistant.Message(
        assistantId: "{assistantId}",
        sessionId: "{sessionId}",
        input: new MessageInput()
        {
            Text = "Hello"
        },
        context: new MessageContext()
        {
            Global = new MessageContextGlobal()
            {
                System = new MessageContextGlobalSystem()
                {
                    UserId = "my_user_id"
                }
            },
            Skills = skills
        }
        );
    
    Console.WriteLine(result.Response);
  • package main
    
    import (
      "encoding/json"
      "fmt"
      "github.com/IBM/go-sdk-core/core"
      "github.com/watson-developer-cloud/go-sdk/assistantv2"
    )
    
    func main() {
      authenticator := &core.CloudPakForDataAuthenticator{
        URL: "https://{cpd_cluster_host}{:port}",
        Username: "{username}", 
        Password: "{password}",
      }
    
      options := &assistantv2.AssistantV2Options{
        Version: "2020-04-01",
        Authenticator: authenticator,
      }
    
      assistant, assistantErr := assistantv2.NewAssistantV2(options)
    
      if assistantErr != nil {
        panic(assistantErr)
      }
    
      assistant.SetServiceURL("{url}")
    
      result, response, responseErr := assistant.Message(
        &assistantv2.MessageOptions{
          AssistantID: core.StringPtr("{assistant_id}"),
          SessionID: core.StringPtr("{session_id}"),
          Input: &assistantv2.MessageInput{
            MessageType: core.StringPtr("text"),
            Text: core.StringPtr("Hello"),
         },
        },
      )
      if responseErr != nil {
        panic(responseErr)
      }
      b, _ := json.MarshalIndent(result, "", "  ")
      fmt.Println(string(b))
    }
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
    Assistant assistant = new Assistant("2020-04-01", authenticator);
    assistant.setServiceUrl("{url}");
    
    MessageInput input = new MessageInput.Builder()
      .messageType("text")
      .text("Hello")
      .build();
    
    MessageOptions options = new MessageOptions.Builder("{assistant_id}", "{session_id}")
      .input(input)
      .build();
    
    MessageResponse response = assistant.message(options).execute().getResult();
    
    System.out.println(response);
  • CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("https://{cpd_cluster_host}{:port}", "{username}", "{password}");
    Assistant assistant = new Assistant("2020-04-01", authenticator);
    assistant.setServiceUrl("{url}");
    
    MessageInputOptions inputOptions = new MessageInputOptions.Builder()
      .returnContext(true)
      .build();
    
    MessageInput input = new MessageInput.Builder()
      .messageType("text")
      .text("Hello")
      .options(inputOptions)
      .build();
    
    MessageContextGlobalSystem system = new MessageContextGlobalSystem.Builder()
      .userId("my_user_id")
      .build();
    MessageContextGlobal globalContext = new MessageContextGlobal.Builder()
      .system(system)
      .build();
    
    Map<String, Object> userDefinedContext = new HashMap<>();
    userDefinedContext.put("account_num","123456");
    MessageContextSkill mainSkillContext = new MessageContextSkill.Builder()
      .userDefined(userDefinedContext)
      .build();
    MessageContextSkills skillsContext = new MessageContextSkills();
    skillsContext.put("main skill", mainSkillContext);
    
    MessageContext context = new MessageContext.Builder()
      .global(globalContext)
      .skills(skillsContext)
      .build();
    
    MessageOptions options = new MessageOptions.Builder()
      .assistantId("{assistant_id}")
      .sessionId("{session_id}")
      .input(input)
      .context(context)
      .build();
    
    MessageResponse response = service.message(options).execute().getResult();
    
    System.out.println(response);
  • const AssistantV2 = require('ibm-watson/assistant/v2');
    const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
    
    const assistant = new AssistantV2({
      version: '2020-04-01',
      authenticator: new CloudPakForDataAuthenticator({
        username: '{username}',
        password: '{password}',
        url: 'https://{cpd_cluster_host}{:port}',
      }),
      serviceUrl: '{url}',
    });
    
    assistant.message({
      assistantId: '{assistant_id}',
      sessionId: '{session_id}',
      input: {
        'message_type': 'text',
        'text': 'Hello'
        }
      })
      .then(res => {
        console.log(JSON.stringify(res.result, null, 2));
      })
      .catch(err => {
        console.log(err);
      });
  • const AssistantV2 = require('ibm-watson/assistant/v2');
    const { CloudPakForDataAuthenticator } = require('ibm-watson/auth');
    
    const assistant = new AssistantV2({
      version: '2020-04-01',
      authenticator: new CloudPakForDataAuthenticator({
        username: '{username}',
        password: '{password}',
        url: 'https://{cpd_cluster_host}{:port}',
      }),
      serviceUrl: '{url}',
    });
    
    assistant.message({
      assistantId: '{assistant_id}',
      sessionId: '{session_id}',
      input: {
        'message_type': 'text',
        'text': 'Hello',
        'options': {
          'return_context': true
        }
      },
      context: {
        'global': {
          'system': {
            'user_id': 'my_user_id'
          }
        },
        'skills': {
          'main skill': {
            'user_defined': {
              'account_number': '123456'
            }
          }
        }
      }
    })
      .then(res => {
        console.log(JSON.stringify(res.result, null, 2));
      })
      .catch(err => {
        console.log(err);
      });
  • import json
    from ibm_watson import AssistantV2
    from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
    
    authenticator = CloudPakForDataAuthenticator(
        '{username}',
        '{password}',
        'https://{cpd_cluster_host}{:port}'
    )
    assistant = AssistantV2(
        version='2020-04-01',
        authenticator = authenticator
    )
    
    assistant.set_service_url('{url}')
    
    response = assistant.message(
        assistant_id='{assistant_id}',
        session_id='{session_id}',
        input={
            'message_type': 'text',
            'text': 'Hello'
        }
    ).get_result()
    
    print(json.dumps(response, indent=2))
  • import json
    from ibm_watson import AssistantV2
    from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
    
    authenticator = CloudPakForDataAuthenticator(
        '{username}',
        '{password}',
        'https://{cpd_cluster_host}{:port}'
    )
    assistant = AssistantV2(
        version='2020-04-01',
        authenticator = authenticator
    )
    
    assistant.set_service_url('{url}')
    
    response=assistant.message(
        assistant_id='{assistant_id}',
        session_id='{session_id}',
        input={
            'message_type': 'text',
            'text': 'Hello',
            'options': {
                'return_context': True
            }
        },
        context={
            'global': {
                'system': {
                    'user_id': 'my_user_id'
                }
            },
            'skills': {
                'main skill': {
                    'user_defined': {
                        'account_number': '123456'
                    }
                }
            }
        }
    ).get_result()
    
    print(json.dumps(response, indent=2))
  • require "json"
    require "ibm_watson/authenticators"
    require "ibm_watson/assistant_v2"
    include IBMWatson
    
    authenticator = Authenticators::CloudPakForDataAuthenticator.new(
      username: "{username}",
      password: "{password}",
      url: "https://{cpd_cluster_host}{:port}"
    )
    
    assistant = AssistantV2.new(
      version: "2020-04-01",
      authenticator: authenticator
    )
    assistant.service_url = "{url}"
    
    response = assistant.message(
      assistant_id: "{assistant_id}",
      session_id: "{session_id}",
      input: {
        text: "Hello"
      }
    )
    
    puts JSON.pretty_generate(response.result)
  • require "json"
    require "ibm_watson/authenticators"
    require "ibm_watson/assistant_v2"
    include IBMWatson
    
    authenticator = Authenticators::CloudPakForDataAuthenticator.new(
      username: "{username}",
      password: "{password}",
      url: "https://{cpd_cluster_host}{:port}"
    )
    
    assistant = AssistantV2.new(
      version: "2020-04-01",
      authenticator: authenticator
    )
    assistant.service_url = "{url}"
    
    response = assistant.message(
      assistant_id: "{assistant_id}",
      session_id: "{session_id}",
      input: {
        text: "Hello"
      },
      context: {
        "global": {
          "system": {
            "user_id": "my_user_id"
          }
        },
        "skills": {
          "main skill": {
            "user_defined": {
              "account_number": "123456"
            }
          }
        }
      }
    )
    
    puts JSON.pretty_generate(response.result)
  • let authenticator = WatsonCloudPakForDataAuthenticator(username: "{username}", password: "{password}", url: "https://{cpd_cluster_host}{:port}")
    let assistant = Assistant(version: "2020-04-01", authenticator: authenticator)
    assistant.serviceURL = "{url}"
    
    let input = MessageInput(messageType: "text", text: "Hello")
    
    assistant.message(assistantID: "{assistant_id}", sessionID: "{session_id}", input: input) {
      response, error in
    
      guard let message = response?.result else {
        print(error?.localizedDescription ?? "unknown error")
        return
      }
    
      print(message)
    }
  • var authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
    );
    
    while (!authenticator.CanAuthenticate())
        yield return null;
    
    var assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    MessageResponse messageResponse = null;
    assistant.Message(
        callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
        {
            Log.Debug("AssistantV2", "result: {0}", response.Response);
            messageResponse = response.Result;
        },
        assistantId: "{assistantId}",
        sessionId: "{sessionId}",
        input: new MessageInput()
        {
            Text = "Hello"
        }
    );
    
    while (messageResponse == null)
        yield return null;
  • var authenticator = new CloudPakForDataAuthenticator(
        url: "https://{cpd_cluster_host}{:port}",
        username: "{username}",
        password: "{password}"
    );
    
    while (!authenticator.CanAuthenticate())
        yield return null;
    
    var assistant = new AssistantService("2020-04-01", authenticator);
    assistant.SetServiceUrl("{url}");
    
    MessageContextSkills skills = new MessageContextSkills();
    MessageContextSkill skill = new MessageContextSkill();
    skill.UserDefined.Add("account_number", "123456");
    skills.Add("main skill", skill);
    
    MessageResponse messageResponse = null;
    assistant.Message(
        callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
        {
            Log.Debug("AssistantV2", "result: {0}", response.Response);
            messageResponse = response.Result;
        },
        assistantId: "{assistantId}",
        sessionId: "{sessionId}",
        input: new MessageInput()
        {
            Text = "Hello"
        },
        context: new MessageContext()
        {
            Global = new MessageContextGlobal()
            {
                System = new MessageContextGlobalSystem()
                {
                    UserId = "my_user_id"
                }
            },
            Skills = skills
        }
    );
    
    while (messageResponse == null)
        yield return null;

Response

A response from the Watson Assistant service.

A response from the Watson Assistant service.

A response from the Watson Assistant service.