Feature focus: Dynamic options

This new response type enables IBM watsonx Assistant to personalize the user’s experience using back-end data

James Walsh
IBM watsonx Assistant
7 min readFeb 21, 2023

--

All images copyright IBM Corp 2023

*Watson Assistant has been rebranded to watsonx Assistant. Any reference to it in this article refers to its new name.

Unique options for every user

The most recent update to the IBM Watson Assistant Actions builder includes a new response type that lets assistant authors fully leverage the power of writing expressions and calling custom extensions. Assistant authors can now define a user response with Dynamic options, a response type that presents the user with a list of options to choose from using information from a back-end API.

A list of responses generated with Dynamic options

Dynamic options are generated using the data stored in variables. This feature allows you to write actions that enable your assistant to provide customers with an experience that is both efficient and highly personalized.

Here, we present a hypothetical example of a bank’s virtual assistant guiding a customer through an interaction by offering a list of options to choose from generated using the Dynamic options feature. Then, we show how the author created the action with Watson Assistant.

The customer’s view

Our hypothetical customer’s name is Cade. Cade has three credit cards with SK Bank, two personal cards and one business card. He needs to make an emergency $2,000.00 purchase for his business, but first he needs to, as quickly as possible, check that he has enough credit on his business’s credit card to afford the purchase.

He’s had several good experiences recently using the bank’s chat interface to find information, so he logs in to the SK Bank website and begins a session with their virtual assistant. The assistant asks him what he needs help with, and Cade asks the assistant to check the balance on his credit card:

Click images to enlarge

Since Cade has multiple credit cards with SK Bank, the assistant needs to confirm which account balance Cade is inquiring about. The assistant asks Cade which account balance he’d like to check, then offers all three credit cards as button options so Cade can select the appropriate account. All but the last four digits of each account are filtered out in the chat window.

Cade selects xxx-xxxx-xxxx-1789, and the assistant responds with the balance. In less than a minute, Cade was able to confirm the balance on his credit card and can confidently proceed with his purchase.

The author’s view

To create this action, SK Bank’s author needs to create an action that calls out to their back-end API (connected to their assistant via a custom extension) and collects the appropriate variables. Before writing the steps that use Dynamic options, the author writes steps that handle scenarios where the user has either one or zero accounts.

Note, the assistant asks the user to confirm his identity in the initial greeting and collects the user_email variable before the start of this action, meaning it’s ready to use to query the customer account database connected through the extension.

Initial steps:

Step 1 — calling an extension

When creating the action, the author enters “Check my balance” in the Customer starts with field and trains the assistant with several variations on the phrasing. Once the action is triggered by the customer’s input, the assistant automatically queries the extension for the customer’s account information. Since this has to happen in order for the assistant to return an account balance, this step is taken without conditions.

The step calls the extension Credit Card System, uses a /get operation to access the user’s data, and sets the _id parameters to user_email. The extension’s response is saved as a variable and will be used to generate the list of options in a subsequent step.

Step 2 — no account

Now that the assistant has accessed the user’s account information, the next set of steps will be taken with conditions. Step 2 accounts for the possibility that the user asks to check their balance but doesn’t have an account on file.

If the extension query response indicates the user doesn’t have an active account with SK Bank, then the assistant responds asking the user if they would like to open an account.

The author sets the condition for this step such that it will only activate when the custom extension indicates the user has no credit cards with SK Bank.

He writes the condition to check if the list of cards has a ‘size’ of 0, then writes a prompt where the assistant asks the user if they would like to open an account:

As the author develops the action further, he’ll edit this step to prompt a confirmation response (Yes or No) from the user. If the user answers ‘Yes’, the conversation will go to another action where the assistant will guide the user through the application process.

Step 3 — one account

If the extension’s response indicates the user has one account, the assistant automatically returns the balance on that one card. The author sets the variable values for creditcardlistand creditcardbalance before writing the assistant’s response.

The author sets the condition that activates this step as the list of credit cards retrieved in step 1 having a ‘size’ of 1. In this case the user doesn’t need to pick a card or open an account, so the assistant simply returns the balance.

In the Assistant says field, the author writes the assitant’s response and inserts the creditcardbalance variable:

Creating a list with Dynamic options

Step 4 — more than one account

If the extension’s response indicates the user has more than one account, then the assistant needs to confirm which account balance the user is trying to check.

The author sets the condition that activates this step as the list of credit cards retrieved in step 1 having a ‘size’ greater than 1. Since the user has two or more credit cards to choose from, the assistant needs to prompt them to pick a card.

Next, the author sets the variable creditcardlist to the list of cards returned from the extension by assigning step1_extension_response.rowsas the value.

With the proper condition and variables in place, the author is ready to define the user’s response with Dynamic options. The author writes a response in the Assistant says field asking the user to select the account number of the credit card whose balance they want to check.

Then, he uses the following steps to create the assistant’s response and present the user with a list of Dynamic options within that response:

  1. He clicks Define customer response
  2. He clicks the Dynamic toggle
  3. He sets the Source variable to creditcardlist

The assistant will now respond by guiding the user to choose a card and present the user with a list of options based on the credit cards associated with the user ID collected in step 1.

Below is the JSON response returned from the SK Bank API:

The compound JSON object returned by the assistant’s query

The response from the extension contains the full card numbers, which SK Bank does not want appearing in the chat panel or in transcripts of the conversation.

To prevent the full account numbers from appearing, the author clicks Edit response, clicks the Option field, and writes the expression Card ending in x-" +${item}.value.cardnumber.substring(11,15).

The SK Bank assistant is now equipped to confirm a user’s identity, query the extension for their account information, and return a list of options if the user has multiple cards.

Again, the assistant’s response will edit out all but the last four digits of the account. All that’s left is for the assistant to return the balance.

Step 5 — returning the balance

The author closes out the action by setting the parameters for the assistant confirming the user’s balance. He defines the variable creditcardbalance using the information collected in step 4. Looking at the payload format returned by SK Bank’s API, we see that the credit card returned has a “value” object, and inside of that there is a “balance” field:

The JSON object stored in Step 4

Using this information, the author sets the creditcardbalance variable to have a value ${prompt step}.item.value.balance where “prompt step” is the index of the step where Cade picked which credit card balance he wanted to check:

The author writes the assistant’s response as “The balance on your card is $creditcardbalance”. The action now accounts for all of the user’s potential account ‘sizes’.

Learn more

Dynamic options are a powerful way to customize your assistant to provide a personalized experience for your users. To learn more about taking advantage of this response type, consult the following sections of the IBM Watson Assistant product documentation:

  • Dynamic options — instructions for defining dynamic options, mapping examples, and referencing selected items
  • Calling a custom extension — instructions for calling an extension from a step, accessing extension response data, and checking success or failure
  • Writing expressions — using an expression in a step condition, assigning a value to a session variable, and expression syntax

Many thanks to

and for their guidance in writing this article.

--

--

James Walsh
IBM watsonx Assistant

Boston born. Virginia alum. Austin based. UX/UI, LLMs, and other acronyms.