Gain a technical understanding of how Watson’s capabilities can be embedded within an application using the Watson Question API (QAPI). The QAPI provides access to the insight that Watson derives from the question asked on the content it ingested and allows a seamless integration to the application.
- What does the QAPI enable developers to do?
- How does the QAPI support app development?
- How do I embed the capabilities of the Watson platform into an app?
- How are synchronous and asynchronous modes supported by Watson?
- About the JSON interface?
The QAPI enables developers to post questions to Watson and retrieve responses and supporting evidence. The evidence contains supporting information based on the passages in the documents that Watson ingested and may have been trained with.
Developers can customize the interface between the Watson Platform and the user. This is done by customizing the output provided by Watson. This output can be manipulated by an application to drive further application utilities, or it can be delivered straight the user as is.
How does the QAPI support app development?
Watson can be embedded into an application in a number of ways. The question being posed to Watson can come directly from a user or from another component upstream in the application architecture.
The response can be shown to a user asking the question as-is, or it could pass on to another component for additional processing before it’s displayed to a user. It can be used to visually represent the response(s), create a way to ask additional simulated questions or process the answer to obtain additional insights on the interactions. After Watson provides the response, the application developer is responsible to integrate that response seamlessly into their application.
How do I embed the capabilities of the Watson platform into an app?
The capabilities of the Watson platform can be embedded in an app using tools and an Application Programming Interface (API) in one of two ways –
1) Using a customizable User Interface
A prepackaged IBM hosted user experience could be integrated within the customer application via an HTML inline Frame (iframe). An iframe can place another HTML document in a frame. This frame can be customized to look and feel like the target application.
2) Application Programming Interface (API)
The Watson Question API (QAPI) exposes a Representational State Transfer (REST) service interface that allows applications to interact directly with Watson. Using this API, one can pose questions to Watson, retrieve answers, and submit feedback on those answers. In addition to simple question and answers, Watson can provide transparency into the evidence for answers through the REST services. For example, a user can expand the possible answers to show supporting evidence for each from sources such as passages and troubleshooting guides. Other functions like ingesting content in the Watson platform will also be exposed as APIs that can be accessed from within the application.
How are synchronous and asynchronous modes supported by Watson?
Watson supports two ways of using the QAPI – Asynchronous and synchronous
1) Asynchronous mode:
In the asynchronous mode, the question is posted to Watson and the response returns a link to retrieve the answer when it is ready. The server needs to be polled to check if the question has completed processing. A status field in the response will indicate if the question contains the final answer. This mode can also be used if a bulk set of questions need to be submitted to Watson, with the answers being retrieved later.
2) Synchronous mode:
In the synchronous mode, a POST operation sends the question to Watson. The answer is received synchronously. This eliminates the need for a polling logic in the client application. In order to make the request synchronous the following HTTP Header needs to be provided: X-SyncTimeout : <time in seconds> If this Header is absent, asynchronous mode is assumed.
About the JSON interface?
The QAPI supports JSON as the content-type and accept type. The following headers need to be specified during the POST. XML is also supported.
After the required and optional parameters are configured, the question is posted. The interaction between the application and the Watson interface can be observed in the figure below: