Watson Assistant V1

With the IBM Watson Assistant service you can create cognitive agents – virtual agents that combine machine learning, natural language understanding, and integrated dialog scripting tools to provide conversation flows between your apps and your users.

The following example shows how to start a conversation with the Assistant service:

import AssistantV1

let authenticator = WatsonIAMAuthenticator(apiKey: "{apikey}")
let assistant = Assistant(version: "2020-04-01", authenticator: authenticator)
assistant.serviceURL = "{url}"

let workspaceID = getWorkspaceID()
let input = MessageInput(text: "Hello")

assistant.message(workspaceID: "{workspace_id}", input: input) {
  response, error in

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

  print(message)
}

For details on all API operations, including Swift examples, see the API reference.