The Setup of Bring Your Own Search (BYOS) for a Question Answering Service in Watson Assistant

This blog post is about how to set up Bring Your Own Search (BYOS) for the Question Answering Service based on IBM Software in Watson Assistant. The implementation of the Question and answering Service is available on GitHub.

You can find more details about the Bring Your Own Search (BYOS) concept in the medium blog post Bring your own search to IBM Watson Assistant.

The blog post contains following main topics.

  1. Simplified architecture overview
  2. Custom extension for Watson Assistant
  3. Setup of “Bring Your Own Search (BYOS)”
  4. Summary
  5. YouTube video

These are the main steps of the Setup for the question and answering extension using Bring Your Own Search (BYOS) for Watson Assistant.

  1. Deploy a Question Answering Service instance
  2. Watson Assistant Service
  3. Setup an extension for the Question Answering Service instance
  4. Configure your assistant to use the extension
  5. Test the assistant

Here is a short reminder of the dependencies for the Watson Assistant configuration you should be aware of:

You can create from a Watson Assistant Service in the IBM Cloud catalog a Watson Assistant Service Instance based on a pricing plan; this service instance can contain several Assistants. Each Assistant will include its configuration. (you can visit the IBM Cloud documentation for more details)

We will configure one assistant to access a custom search using an extension. This extension will access a Question Answering Service instance deployed on the cloud. (for example, IBM Cloud Code Engine)

The result will look like this:

The first entry is the answer; below, you see the linked resources the AI has used to create the answer.

1. Simplified architecture overview

In the diagram you see, that we will access the “assistant” in the Watson Assistant Service from a Watson Assistant “Web Frontend”. The assistant uses a prepared actions configuration to invoke an extension, and this extension will call a REST API endpoint of a running “Question and Answering Service” in IBM Cloud Code Engine. IBM Cloud Code Engine gets the right container images from a container registry. The “Question and answering service” get its data from a PrimeQA instance installed in a VSI.

2. Custom extension for Watson Assistant

The Question Answering Service instance implements a custom extension for Watson Assistant with Java and Quarkus. If you want to dig a bit more into the topic of “how to write custom extensions?”, you can visit my blog post “Open the door wide open for Watson Assistant with “custom extensions” – an excellent progression“. This blog post shows how to build a simple extension with Node.js, or you can take a look at the IBM Documentation.

3. Setup of example

1. Deploy a Question Answering Service instance.

  1. Deploy an instance of the Question Answering Service, for example, to IBM Cloud Code Engine
  2. Insert your public server https://URL to access the Question Answering Service in the OpenAPI.json file by changing the servers values to your needs.
"`json "servers": [ { "url": "https://YOUR_URL", "description": "YOUR_DESCIPTION" } ],

A server URL doesn’t contain any endpoint invocation.

  "servers": [
      "url": "",
      "description": "My API server on Code Engine"

Note: You can also use a fake implementation for the “Question and answering service” in the container nodejs-assistant-extension on the This implementation doesn’t connect to any search engine and only returns a predefined return value. The needed OpenAPI 3.0.0 specification is available in assistant-extension-query.json file, and the necessary fake response is available in the variable  EXAMPLE_JSON_RETURN for the query API endpoint.

2. Watson Assistant Service

  1. Create a Watson Assistant Service instance
  2. Create a new assistant

Note: You should create a new assistant because we will replace your current actions configuration later!

3. Setup an extension for the Question Answering Service instance

3.1 Create an extension

  1. Select your Assistant instance of your Watson Assistant service.
  2. Open Integration from the side menu
  3. Navigate to the Extensions section
  4. Press Build custom extension
  5. Follow the steps in the wizard and insert the requested values.
    • Get started
    • Basic information
      • Title: Question and answering extension
      • Description: This is the extension to integrate the question and answering microservice via a REST API.
    • Import OpenAPI
    • Review the extension

3.2 Deploy the extension to an assistant environment

An assistant has two minimal environments: Draft and Live. We will add the extension to the Draft environment.

  1. Open Integration from the side menu
  2. Navigate to the Extensions section
  3. Press Add on your created extension in the integration catalog
  4. Select Draft and press Confirm

4. Configure your assistant to use the extension

Now we will import an existing configuration for the assistant actions to use the question and answering extension, and then we will configure the actions and variables to use the extension.

4.1 Import an existing configuration for the actions

  1. Open Actions from the side menu
  2. Select Global settings in the upper right corner
  3. Select the tab Upload/Download
  4. Upload the action JSON file called demo-question-and-answering-action-configuration.json and press Save.

Note: This will replace the current configuration of your existing assistant instance.

4.2 Verify the newly created actions

The following table contains an overview of the created actions and their responsibilities. The numbering represents the order and the execution of the actions.

1-searchThis action handles the user’s search entry and will start the search with the extension. The return values of the search will be saved in variables when a search is successful. Then the action 2-process-result will be invoked.
2-process-resultThis action gives you additional verification possibilities for the search result return values. Then the action 3-select-search-result-to-show will be invoked.
3-select-search-result-to-showThis action selects one of the search’s return values to be displayed later. The configuration of this action defines the number of return values you will display later. Then the action 4-display-search-result will be invoked.
4-display-search-resultThis action is responsible for the search results entries. Here you can define how the result entry will be displayed and add conditions before it is displayed.

4.3 Configure the 1-search action

Now we need to configure the use of the extension of our extension.

  1. You will see that Step 4 is marked red.
  1. Select Edit extension
    1. Configure Extension to use the Question and answering extension.
    2. Configure Operations to use one of the available operations.
    3. Press Apply

Example for a configuration: 

Note: If you don’t see the same result as in the image above, select for the parameter value `query` the option `Expression` in the Set to field and insert `”text:”.concat(${1_req_query_text})` in the text field.

5. Test the assistant

  1. Open Preview from the side menu
  2. Enter demo search: When and for how much did IBM acquire Red Hat?
    The first entry is the answer; below, you see the resources the AI has used to create the answer.

4. Summary

With the concept of the “Bring Your Own Search (BYOS)” and the extension capability, you can set up an integration to a custom search in minutes, as we did in this example.

5. YouTube video

This long (1h) live stream is about how to set up BYOS in Watson Assistant.

  • 1. Deploy Example Node.js Application to IBM Cloud Code Engine
  • 2. The setup of BYOS in Watson Assistant
  • 3. Inspect the setup

Content of the video:

  1. 00:00 Introduction
  2. 04:14 Basic flow for the extension
  3. 09:44 Setup of Code Engine
  4. 22:07 OpenAPI specification and the swagger editor
  5. 26:52 Watson Assistant overview
  6. 29:50 Create Watson Assistant Service instance
  7. 33:34 Add extension to an Assistant
  8. 38:00 Overview Assistant environments
  9. 38:41 Import Actions for BYOS
  10. 40:54 Configure BYOS “1-search “Action
  11. 45:50 Parameter in BYOS “1-search “Action
  12. 48:11 Try out assistant
  13. 50:46 Action invocations
  14. 55:42 Invoke the pod with kubectl for logging in Code Engine
  15. 01:00:00 Summary and ending

I hope this was useful to you, and let’s see what’s next?



#extension, #watsonassistant, #byos, #bringyourownsearch, #codeengine, #ibmcloud

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at

Up ↑

%d bloggers like this: