vania-janet/multiturn-rag-retrieval-data huggingface dataset:
Depending on the design of your application, there are various ways to do this, but one simple mechanism is to check the value of a URL query parameter (in this example, page):

const page = new URLSearchParams(window.location.search).get('page');
2. Create a handler for the [pre:send](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-eventspresend) event, which is fired before a message is sent to the assistant. This handler starts by checking the [is_welcome_request](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-eventsmessageextensions) property to determine whether the message being sent is the empty message that starts the conversation by triggering the Greet customer action.

If it is, the handler then checks the currently displayed page, and it replaces the outgoing empty message with a message that will trigger an action that is specific to the page. (This example only shows setting the message to Credit Cards, but additional if conditions could customize the message for other pages.)

function preSendHandler(event) {
if (event.data.history && event.data.history.is_welcome_request) {
if (page === 'cards') {
event.data.input.text = 'Credit Cards';
}
}
}
3. In your onLoad event handler, use the [once()](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methodsonce) instance method to subscribe to the pre:send event, registering the preSendHandler() function as the callback. (We can use once() instead of on() because this handler needs to be called only for the first message in the session.)

instance.once({ type: 'pre:send', handler: preSendHandler});
In your onLoad event handler, use the [on()](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methodson) instance method to subscribe to the identityTokenExpired event.

In the callback, call the function on your server that you implemented to generate a new JWT. Then use the identityToken parameter of the event to specify the new JWT, as in this example:

instance.on({ type: 'identityTokenExpired',
handler: async function(event) {
const jwtFromServer = await fetch('http://example.com:3001/createJWT');
event.identityToken = jwtFromServer;
}});

The new JWT you specify is automatically sent with each subsequent message from the web chat instance on your web site (until the token expires).

You can also specify the JWT at the beginning of the session by using the identityToken property in the web chat configuration object. However, you will still need to create an event handler for identityTokenExpired, unless you are certain your JWTs will never expire during a session.





 Updating the web chat settings 

Now that you have configured the web chat to send signed JWTs, you can enable web chat security in the web chat integration settings.

After you enable web chat security, messages from any origin other than your web chat instance (which you have configured to send signed JWTs) are rejected. This means that enabling web chat security disables the shareable preview link, which does not send JWTs with messages. For more information about the preview link, see [Copying a link to share](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-preview-sharepreview-share-link).

To enable security, complete the following steps:



1. On the Security tab of the web chat integration settings, set the Secure your web chat switch to On.
2.
: The service can be installed on-premises in environments where IBM Cloud Pak for Data 2.5 is installed on OpenShift or standalone. See the [IBM Cloud Pak for Data documentation](https://www.ibm.com/support/knowledgecenter/SSQNUZ_2.5.0/cpd/svc/watson/assistant-overview.html) for more information.





 26 February 2020 

Slot Save it as field retains your edits
: When you edit what gets saved for a slot by using the JSON editor to edit the value of the context variable to be something other than what is specified in the Check for field, your changes are kept even if someone subsequently clicks the Save it as field.





 20 February 2020 

Access control changes are coming
: Notifications are displayed in the user interface for anyone with Reader and Writer level access to a service instance. The notification explains that access control is going to change soon, and that what they can do in the instance will change unless they are given Manager service access beforehand. For more information, see [Preventing loss of access](https://cloud.ibm.com/docs/assistant?topic=assistant-access-control).





 14 February 2020 

More web chat color settings
: You can now specify the color of more elements of the web chat integration. For example, you can define one color for the web chat window header. You can define a different color for the user message bubble. And another color for interactive components, such as the launcher button for the chat.





 13 February 2020 

Track API events
: Premium plan users can now use the Activity Tracker service to track how users and applications interact with IBM Watson® Assistant in IBM Cloud®. See [Activity Tracker events](https://cloud.ibm.com/docs/assistant?topic=assistant-at-events).





 5 February 2020 

New API version
: The current API version is now 2020-02-05. The following changes were made with this version:



* When a dialog node's response type is connect-to-agent, the node's title is used as the topic value. Previously, user_label was used.
An embeddable URL is one that can be specified as the value of the src attribute of the iframe element.

For example, to embed an interactive map using Google Maps, you can use the Google Maps Embed API. (For more information, see [The Maps Embed API overview](https://developers.google.com/maps/documentation/embed/get-started).) Other sites have different processes for creating embeddable content.

For technical details about using Content-Security-Policy: frame-src to allow embedding of your website content, see [CSP: frame-src](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src).
3. Optionally add a descriptive title in the Title field.

In the web chat, this title will be displayed in the preview card before the customer clicks to render the external content. (If you do not specify a title, the web chat will attempt to retrieve metadata from the specified URL and display the title of the content as specified at the source.)
4. The iframe response type is supported in the web chat and Facebook integrations.



In the "Try it out" pane, the iframe is rendered immediately, without the preview card. To see how the web chat renders your response, use the assistant Preview page.



 Technical details: <iframe> sandboxing 

Content loaded in an iframe by the web chat is sandboxed, meaning that it has restricted permissions that reduce security vulnerabilities. The web chat uses the sandbox attribute of the iframe element to grant only the following permissions:



 Permission Description 

 allow-downloads Allows downloading files from the network, if the download is initiated by the user. 
 allow-forms Allows submitting forms. 
 allow-scripts Allows running scripts, but not opening pop-up windows. 
 allow-same-origin Allows the content to access its own data storage (such as cookies), and allows only very limited access to JavaScript APIs.
Release notes for Watson Assistant for IBM Cloud Pak® for Data 

Use these release notes to learn about the latest updates to IBM Watson® Assistant for IBM Cloud Pak® for Data.



 Feature availability 

Some features that are available with Watson Assistant for cloud are not available with Watson Assistant for IBM Cloud Pak® for Data. For a list of features that are not available with Watson Assistant for IBM Cloud Pak® for Data, see [About Watson Assistant](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-indexindex-available-features).





 Web chat versions 

When you install Watson Assistant for IBM Cloud Pak® for Data, the latest available version of the web chat integration is included. See the following table for details about the latest available web chat version for each Watson Assistant for IBM Cloud Pak® for Data release. If your web chat version isn't locked, then the web chat integration is upgraded to the latest available version when you upgrade Watson Assistant for IBM Cloud Pak® for Data.

The following table shows the latest version of the web chat integration that is included with each release of Watson Assistant for IBM Cloud Pak® for Data. IBM Cloud Pak® for Data supports web chat versions 5.1.1 or later. To customize and change version numbers, see [Controlling the web chat version](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-web-chat-develop-versions).



Web chat versions in Watson Assistant for IBM Cloud Pak® for Data

 Watson Assistant for IBM Cloud Pak® for Data version Latest web chat version available 

 4.7.0 [7.3.0](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-release-notes-chat7.3.0) 
 4.6.5 [7.2.0](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-release-notes-chat7.2.0) 
 4.6.3 [7.1.0](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-release-notes-chat7.1.0)
Encrypting sensitive data 

By using the public key that is provided by IBM, you can add another level of encryption to hide sensitive data you send from the web chat.

To use this method for encrypting data, you must first enable the web chat security feature. For more information, see [Enabling web chat security](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-web-chat-security-enable).

Use this method to send sensitive information in messages that come from your website, such as information about a customer's loyalty level, a user ID, or security tokens to use in webhooks that you call from actions. Information passed to your assistant in this way is stored in a private context variable. Private variables cannot be seen by customers and are never sent back to the web chat.

For example, you might start a business process for a VIP customer that is different from the process you start for a standard customer. You do not want non-VIPs to know that they are categorized as such, but you must pass this information to your action so it can change the flow of the conversation. To do this, you can pass the customer MVP status as an encrypted variable. This private context variable is available for use by the action, but not by anything else.

![development icon](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/development-icon.png)Tutorial: For a tutorial that shows an example of using web chat security to authenticate users and protect sensitive data, see [Tutorial: Authenticating a user in the middle of a session](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-web-chat-develop-security).

To encrypt sensitive data:



1. On the Security tab of the web chat integration settings, click the Generate key button.
2. Copy the public key that displays in the IBM-provided public key field.
"preference": "button",
"options":
{
"label": "Buy something",
"value": {
"input": {
"text": "Place order"
}
}
},
{
"label": "Exit",
"value": {
"input": {
"text": "Exit"
}
}
}
]
}
]
}
Show more







 pause 

Pauses before sending the next message to the channel, and optionally sends a "user is typing" event (for channels that support it).



 Integration channel support 



 Web chat Facebook WhatsApp 

 ![Yes](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/checkmark-icon.svg) ![Yes](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/checkmark-icon.svg) ![Yes](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/checkmark-icon.svg) 





* With the phone integration, you can add a pause by including the SSML break element in the assistant output. For more information, see the [Text to Speech documentation](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-elementsbreak_element).







 Fields 



 Name Type Description Required? 

 response_type string pause Y 
 time int How long to pause, in milliseconds. Y 
 typing boolean Whether to send the "user is typing" event during the pause.
At run time, the web chat integration shows an options response as a set of clickable buttons or as a drop-down list, depending on the number of choices. SmallMediumLarge 
 [Confirmation](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-confirmation) A choice of either Yes or No. At run time, the web chat integration shows the Yes and No options as clickable buttons. Yes, No 
 [Regex](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-regex) A text response that matches a specified pattern or format (such as an email address or telephone number). 
 [Number](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-number) A single generic number, specified either as numerals (100) or words (one hundred). 100, one hundred 
 [Date](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-date) A single specific date or a range of dates. 31 December 2021, 12/31/2020, tomorrow 
 [Time](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-time) A single specific time or a range of time. 5:00 PM, now 
 [Currency](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-currency) An amount of money, including the unit. $25, 500 yen 
 [Percent](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-infocustomer-response-type-percent) A fractional numeric value that is expressed as a percentage. 10%, 50 percent
[instance.updateHistoryUserDefined()](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-instance-methodsupdateHistoryUserDefined) provides a way to save state for any message response. With the state saved, a response can be rerendered with the same state. This saved state is available in the history.user_defined section of the message response on reload. The data is saved during the user session. When the session expires, the data is discarded.

Two new history events, [history:begin](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-eventshistorybegin) and [history:end](https://web-chat.global.assistant.watson.cloud.ibm.com/docs.html?to=api-eventshistoryend) announce the beginning and end of the history of a reloaded session. These events can be used to view the messages that are being reloaded. The history:begin event allows you to edit the messages before they are displayed.

See this example for more information on saving the state of [customResponse](https://web-chat.global.assistant.watson.cloud.ibm.com/testfest.html?to=api-eventscustomresponse) types in session history.
* Channel switching: You can now create a dialog response type to functionally generate a connect-to-agent response within channels other than web chat. If a user is in a channel such as Slack or Facebook, they can trigger a channel transfer response type. The user receives a link that forwards them to your organization's website where a connection to an agent response can be started within web chat. For more information, see [Adding a Channel transfer response type](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overviewdialog-overview-add-channel-transfer).







 3.5.0 

Release date: 17 February 2021



* Session history (beta): Web chat session history (beta) is now available.
Tutorial: Authenticating a user in the middle of a session 

If you have web chat security enabled, you must set a user ID for the customer at the beginning of the session as part of the JSON Web Token (JWT) you use to sign messages. For users who are not authenticated, this is typically a generated ID, and it cannot be changed after the JWT is created. However, you can use a private variable to authenticate a user later in the session.

With web chat security enabled, the user ID associated with each message is based on the sub claim in the JWT payload. This value must be set at the beginning of the session, when the JWT is created, and cannot be changed during the life of the session. For unauthenticated (anonymous) users, you would typically use a generated ID, saved to a cookie, to ensure that each unique customer is counted only once for billing purposes.

However, you might want your customers to be able to authenticate in the middle of a session (for example, to complete an action that updates the user's account information). Because the generated user ID in the sub claim cannot be changed, you need another way to authenticate the user securely. You can do this by storing the customer's actual authenticated user ID as a private variable in the user payload of the JWT. (You could store the user ID in an ordinary context variable, but this would not be secure, because such variables can be modified.)

For a complete, working version of the example described in this tutorial, see [Enabling security for Watson Assistant web chat](https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/webchat/examples/web-chat-security).

This example in this tutorial, which is based on an Express server for Node.js, shows how to start a session with an anonymous user ID and then authenticate the user during the session.



1. Create a function called getOrSetAnonymousID() that generates a unique anonymous user ID for each customer and stores it in a cookie (or, if the cookie already exists, uses the stored user ID).

Use a cookie that lasts for at least 45 days.
On this page[Making a basic HTTP speech recognition request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-httpHTTP-basic)[Basic request example](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-httpHTTP-basic-example)[Making a multipart HTTP speech recognition request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-httpHTTP-multi)


Feedback

Focus sentinel

 Give us your feedback 

Tell us about your experience0/1500



Don't include any sensitive or personal information.

How satisfied are you with your experience?

How satisfied are you with your experience?

1

2

3

4

5

info icon

Your feedback is carefully reviewed, but you won't be contacted in response. Need help? Try searching the docs or chatting with the Virtual Assistant in console.

Cancel

Submit

Focus sentinel Cookie Preferences

Your privacy choices

Your privacy choices

![0_ti_146001191_Ver_2_mid_72b37ccf-47a9-473e-ba6b-b554aa8c2367_sid_cca51480229211eeac887b94c5a6c542_vid_cca50460229211ee874f7dc32b9b9a8d_vids_0_msclkid_N_pi_918639831_lg_en-US_sw_3840_sh_
word_confidence: true,
timestamps: true
};
websocket.send(JSON.stringify(message));





 Keep a connection alive 

The service terminates the session and closes the connection if an inactivity or session timeout occurs:



* An inactivity timeout occurs if audio is being sent by the client but the service detects no speech. The inactivity timeout is 30 seconds by default. You can use the inactivity_timeout parameter to specify a different value, including -1 to set the timeout to infinity. For more information, see [Inactivity timeout](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-inputtimeouts-inactivity).
* A session timeout occurs if the service receives no data from the client or sends no interim results for 30 seconds. You cannot change the length of this timeout, but you can extend the session by sending the service any audio data, including just silence, before the timeout occurs. You must also set the inactivity_timeout to -1. You are charged for the duration of any data that you send to the service, including the silence that you send to extend a session. For more information, see [Session timeout](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-inputtimeouts-session).



WebSocket clients and servers can also exchange ping-pong frames to avoid read timeouts by periodically exchanging small amounts of data. Many WebSocket stacks exchange ping-pong frames, but some do not. To determine whether your implementation uses ping-pong frames, check its list of features. You cannot programmatically determine or manage ping-pong frames.

If your WebSocket stack does not implement ping-pong frames and your are sending long audio files, your connection can experience a read timeout. To avoid such timeouts, continuously stream audio to the service or request interim results from the service. Either approach can ensure that the lack of ping-pong frames does not cause your connection to close.
Comparing actions and dialog 

Choose the right type of conversation for your use case.



 Actions benefits 

Using actions is the best choice when you want to approach the assistant with a focus on content. Actions offers the following benefits:



* The process of creating a conversational flow is easier. People who have expertise with customer care can write the words that your assistant says. With a simplified process anyone can build a conversation. You don't need knowledge about machine learning or programming.
* Actions provide better visibility into the customer's interaction and satisfaction with the assistant. Because each task is discrete and has a clear beginning and ending, you can track user progress through a task and identify snags.
* The conversation designer doesn't need to manage data collected during the conversation. By default, your assistant collects and stores information for the duration of the current action. You don't need to take extra steps to delete saved data or reset the conversation. But if you want, you can store certain types of information, such as the customer's name, for the duration of a conversation.
* Many people can work at the same time in separate, self-contained actions. The order of actions within a conversation doesn't matter. Only the order of steps within an action matters. And the action author can use drag and drop to reorganize steps in the action for optimal flow.







 Dialog benefits 

A dialog-based conversation is the best choice when you want greater control over the logic of the flow. The dialog editor exposes more of the underlying artifacts (such as intents and entities) used to build the AI models. The dialog flow uses an if-then-else style structure that might be familiar to developers, but not to content designers or customer-care experts.





 How actions are different from dialog 

If you are already familiar with dialog-based conversations, learn more about how actions compares.



Conversational flow skill feature support
This table has row and column headers. The row headers identify features. The column headers identify the different skill types. To understand which features are supported by a skill, go to the row that describes the feature, and find the columns for the skill you are interested in.