vania-janet/multiturn-rag-retrieval-data huggingface dataset:
* Jump to another dialog node: Use this option when you want the conversation to go directly to an entirely different dialog node. You can use a Jump to action to route the flow to a common dialog node from multiple locations in the tree, for example.

The target node that you want to jump to must exist before you can configure the jump to action to use it.





 Configuring the Jump to action 

If you choose to jump to another node, specify when the target node is processed by choosing one of the following options:



* Condition: If the statement targets the condition section of the selected dialog node, your assistant checks first whether the condition of the targeted node evaluates to true.



* If the condition evaluates to true, the system processes the target node immediately.
* If the condition does not evaluate to true, the system moves to the next sibling node of the target node to evaluate its condition, and repeats this process until it finds a dialog node with a condition that evaluates to true.
* If the system processes all the siblings and none of the conditions evaluate to true, the basic fallback strategy is used, and the dialog evaluates the nodes at the base level of the dialog tree.



Targeting the condition is useful for chaining the conditions of dialog nodes. For example, you might want to first check whether the input contains an intent, such as turn_on, and if it does, you might want to check whether the input contains entities, such as @lights, @radio, or @wipers. Chaining conditions helps to structure larger dialog trees.

Avoid choosing this option when configuring a jump-to from a conditional response that goes to a node situated above the current node in the dialog tree. Otherwise, you can create an infinite loop. If your assistant jumps to the earlier node and checks its condition, it is likely to return false because the same user input is being evaluated that triggered the current node last time through the dialog. Your assistant will go to the next sibling or back to root to check the conditions on those nodes, and will likely end up triggering this node again, which means the process will repeat itself.
* Response: If the statement targets the response section of the selected dialog node, it is run immediately.
Making a call before processing a message 

A premessage webhook makes a call to an external service or application every time a customer submits input. The external service can process the message before it is processed by your assistant.

Add a premessage webhook to your assistant if you want the webhook to be triggered before each incoming message is processed by your assistant.

If you are using a custom channel, note that the premessage webhook works with the v2 /message API only (stateless and stateful). For more information, see the [API reference](https://cloud.ibm.com/apidocs/assistant/assistant-v2message). All built-in channel integrations use this API.

You can use a premessage webhook to do the following types of things:



* Translate the customer's input to the language that is used by your assistant.
* Check for and remove any personally identifiable information, such as an email address or social security number that a customer might submit.



You can use this webhook in coordination with the postmessage webhook. For example, the postmessage webhook can do things like translate the response back into the customer's native language or add back information that was removed for privacy reasons. For more information, see [Making a call after processing a message](https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-post).

For environments where private endpoints are in use, keep in mind that a webhook sends traffic over the internet.



 Defining the webhook 

You can define one webhook URL to use for preprocessing every incoming message.

The programmatic call to the external service must meet these requirements:



* The call must be a POST HTTP request.
* The request body must be a JSON object (Content-Type: application/json).
* The call must return in 30 seconds or less.



If your external service supports only GET requests, or if you need to specify URL parameters dynamically at run time, consider creating an intermediate service that accepts a POST request with a JSON payload containing any runtime values.
This diagram illustrates how IBM Watson® Assistant delivers an exceptional, omnichannel customer experience:

Zoom

![Flow diagram of the service](https://cloud.ibm.com/docs-content/v1/content/ca9232b3702768f24bb897f48f10778fcda28718/watson-assistant/images/arch-detail.png)

How it works

Customers interact with the assistant through one or more of these channels:



* A web chat that you embed in your company website and that can transfer complex requests to a customer support representative.
* An existing social-media messaging platform, such as Slack, Facebook Messenger, or WhatsApp
* A phone call or text message
* A custom application that you develop, such as a mobile app or a robot with a voice interface



The assistant receives a message from a customer and sends it down the appropriate resolution path.

If you want to preprocess incoming messages, this is where you can use webhooks to inject logic that calls an external service that can process the messages before the assistant routes them. Likewise, you can process responses from the assistant before they are returned to the customer.

The assistant chooses the appropriate resolution from among these options:



* An action interprets the customer's message further, then directs the flow of the conversation. The action gathers any information it needs to respond or perform a transaction on the customer's behalf.
* A search integration uses existing FAQ or other curated content that you own to find relevant answers to customer questions.
* If a customer wants more personalized help or wants to discuss a sensitive subject, the assistant can connect the customer with someone from your support team through the web chat or phone integration.



To see how Watson Assistant is helping enterprises cut costs and improve customer satisfaction today, read the [Independent study finds IBM Watson Assistant customers can accrue $23.9 million in benefits](https://www.ibm.com/blogs/watson/2020/03/independent-study-finds-ibm-watson-assistant-customers-accrued-23-9-million-in-benefits/) blog on ibm.com.

Read more about these implementation steps by following these links:
You can see the implementation of this helper function in the [full example](https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/webchat/examples/download-history).

function createDownload() {
const downloadLines = [createDownloadText('From', 'Message')];

messages.forEach(message => {
if (message.input?.text) {
// This is a message that came from the user.
downloadLines.push(createDownloadText('You', message.input.text));
} else if (message.output?.generic?.length) {
// This is a message that came from the assistant. It can contain an array of individual message items.
message.output?.generic.forEach(messageItem => {
// This is only handling a text response but you can handle other types of responses here as well as
// custom responses.
if (messageItem?.text) {
downloadLines.push(createDownloadText('Lendyr', messageItem.text));
}
});
}
});

return downloadLines.join('n');
}
Show more
5. Create a function that initiates the download of the conversation history file. This function calls the createDownload() function to generate the content to download. It then simulates clicking a link to start the download, using a file name generated from the current date.

function doDownload() {
const downloadContent = createDownload();

const blob = new Blob([downloadContent], { type: 'text/csv' });
const url = URL.createObjectURL(blob);

// To automatically trigger a download, we have to create a fake "a" element and then click it.
[Learn more](https://cloud.ibm.com/docs/assistant?topic=assistant-entities). 
 Integrations Ways you can deploy your assistant to existing platforms or social media channels. [Learn more](https://cloud.ibm.com/docs/assistant?topic=assistant-deploy-integration-add). 
 Intent The goal that is expressed in the user input, such as answering a question or processing a bill payment. [Learn more](https://cloud.ibm.com/docs/assistant?topic=assistant-intents). 
 Message A single turn within a conversation that includes a single call to the /message API endpoint and its corresponding response. 
 Monthly active user (MAU) A single unique user who interacts with an assistant one or many times in a given month. 
 Preview Embeds your assistant in a chat window that is displayed on an IBM-branded web page. From the preview, you can test how a conversation flows through any and all skills that are attached to your assistant, from end to end. [Learn more](https://cloud.ibm.com/docs/assistant?topic=assistant-deploy-web-link). 
 Response Logic that is defined in the Assistant responds section of a dialog node that determines how the assistant responds to the user. When the node's condition evaluates to true, the response is processed. The response can consist of an answer, a follow-up question, a webhook that sends a programmatic request to an external service, or slots which represent pieces of information that you need the user to provide before the assistant can help. The dialog node response is equivalent to a Then statement in If-Then-Else programming logic. 
 Skill Does the work of the assistant. A dialog skill has the training data and dialog that your assistant uses to chat with customers. An actions skill is a new way to build a conversation. Actions offer step-by-step flows for a conversations and are made so that anybody can build them. A search skill is configured to search the appropriate external data sources for answers to customer questions. [Learn more](https://cloud.ibm.com/docs/assistant?topic=assistant-skill-add).
}" "{url}/v1/synthesize?voice=en-US_AllisonV3Voice&pitch_percentage=5"

The following WebSocket example shows inclusion of the parameter with the same value on the request to establish a connection:

var access_token = '{access_token}';
var wsURI = '{ws_url}/v1/synthesize'
+ '?access_token=' + access_token
+ '&voice=en-US_AllisonV3Voice'
+ '&pitch_percentage=5';
var websocket = new WebSocket(wsURI);







 Specifying how strings are spelled out 

The service's default pronunciation of alphabetic, numeric, and alphanumeric strings varies by language, with each language having its own rules. For any language, the pronunciation also depends on the length and context of the string, as well its composition in terms of the positions and grouping of its characters



* Alphabetic strings are pronounced as words if they are pronounceable in the language of the voice. Otherwise, the characters are spelled out individually. Whether a string is pronounced or spelled out can also depend on the case of the letters.
* Numeric strings can be pronounced as cardinal numbers, ordinal numbers, dates, or in other ways, including as individual digits.
* Alphanumeric strings that contain both letters and numbers can be pronounced in different ways depending on the characteristics of the string. For example, they might be pronounced as combinations of words, cardinal numbers, or digits. But as mentioned previously, the pronunciation depends largely on the string and its composition.



The best means of controlling how a specific string is pronounced is to use the <say-as> element of the SSML. The element allows you to specify exactly how a string is synthesized. You use the interpret-as attribute of the <say-as> element to indicate that a string of characters is to be pronounced as letters, digits, or in some other way. The available values differ by language.

If you use the letters or digits attributes, all letters and numbers of the string are pronounced individually.
Activate a credit card Your assistant can use a conversational flow to collect information for identity verification, and then call a webhook to submit the request to activate the card on the user's behalf. 
 Complete a simple task that involves a complicated application Your assistant can link them to a 2-minute video that illustrates how to complete the task. 
 Learn about insurance plan details after the death of a loved one Your assistant can connect the customer directly to a person who can show empathy and patience as the matter is addressed. 
 Solve a problem that requires a long and involved procedure to fix Instead of trying to walk the customer through the procedure step by step in conversation, your assistant can link to a help center that documents the full procedure in detail. 
 The customer calls support and your assistant answers Let's say the assistant needs a lot of details from the customer before it can help. Instead of trying to prompt the customer for each piece of information and transcribe it properly, your assistant can switch to SMS text messaging. After years of interacting with bad interactive voice response systems, many customers are more likely to yell Agent over and over than to engage in a long exchange. But if you give them a chance to explain something in writing, they tend to do so willingly. 







 How will customers find your assistant? 

Deploy your assistant where customers can find it with ease. For example, you can embed the assistant in your company website or add it to a messaging platform such as Facebook, Slack, or WhatsApp.

While the conversational skill is defined in text, customers can talk with your assistant over the phone when you deploy it by using the phone integration.

For more information about ways to deploy the assistant, see [Adding integrations](https://cloud.ibm.com/docs/assistant?topic=assistant-deploy-integration-add).

Understanding where you will deploy the assistant before you begin can help you author the right types of answers for a given channel or platform.





 What languages does your assistant speak? 

Decide whether and how you want to handle more than one spoken language. For more information about ways to approach language support, see [Adding support for global audiences](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-language).





 Does your assistant see the glass as half full?
[Learn more](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-entities). 
 Integrations Ways you can deploy your assistant to existing platforms or social media channels. [Learn more](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-deploy-integration-add). 
 Intent The goal that is expressed in the user input, such as answering a question or processing a bill payment. [Learn more](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-intents). 
 Message A single turn within a conversation that includes a single call to the /message API endpoint and its corresponding response. 
 Monthly active user (MAU) A single unique user who interacts with an assistant one or many times in a given month. 
 Preview link An integration that builds embeds your assistant in a chat window that is displayed on an IBM-branded web page. From the preview link integration, you can test how a conversation flows through any and all skills that are attached to your assistant, from end to end. [Learn more](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-deploy-web-link). 
 Response Logic that is defined in the Assistant responds section of a dialog node that determines how the assistant responds to the user. When the node's condition evaluates to true, the response is processed. The response can consist of an answer, a follow-up question, a webhook that sends a programmatic request to an external service, or slots which represent pieces of information that you need the user to provide before the assistant can help. The dialog node response is equivalent to a Then statement in If-Then-Else programming logic. 
 Skill Does the work of the assistant. A dialog skill has the training data and dialog that your assistant uses to chat with customers. An actions skill is a new way to build a conversation. Actions offers step-by-step flows for a range of simple or complex conversations and is made so that anybody can build. A search skill is configured to search the appropriate external data sources for answers to customer inquiries.
This documentation is for the classic Watson Assistant experience. To see the documentation for the new Watson Assistant, please go [here](https://cloud.ibm.com/docs/watson-assistant).



 Webhook overview 

Make a call to an external service or application during a conversation.

Watson Assistant supports the following types of webhooks:



* Skill-level webhooks

The following type of webhook can be set up for use from a dialog skill:



* [Dialog](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks)



* Assistant-level webhooks

The following types of webhooks can be set up for an assistant:



* [Logs](https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-log)
* [Premessage](https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-pre)
* [Postmessage](https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-post)







 Which type of webhook should I use? 

The skill-level webhook is different from the assistant-level webhooks in the following ways:



* Frequency with which the webhooks is called

The dialog webhook is called on the rare occasion that the dialog node from which it is triggered is processed.

The message processing webhooks are called with every single exchange in a conversation between the customer and the assistant.

The log webhook is called with each message and its corresponding response.
* Where the condition is defined

For a dialog webhook, the condition to meet before an action is taken is defined in the dialog skill. If the node condition is not met, then the dialog webhook is never called.

For the message processing webhooks, the condition to check for before taking an action must be defined in the external application code.
function sendMessage(messageInput) {
service
.message({
assistantId,
sessionId,
input: messageInput,
})
.then(res => {
processResponse(res.result);
})
.catch(err => {
console.log(err); // something went wrong
});
}

// Process the response.
function processResponse(response) {

let endConversation = false;
let promptOption = false;

// Check for client actions requested by the assistant.
if (response.output.actions) {
if (response.output.actions[0].type === 'client'){
if (response.output.actions[0].name === 'display_time') {
// User asked what time it is, so we output the local system time.
console.log('The current time is ' + new Date().toLocaleTimeString() + '.');
} else if (response.output.actions[0].name === 'end_conversation') {
// User said goodbye, so we're done.
console.log(response.output.generic[0].text);
endConversation = true;
}
}
} else {
// Display the output from assistant, if any. Supports only a single
// response.
if (response.output.generic) {
if (response.output.generic.length > 0) {
switch (response.output.generic[0].response_type) {
case 'text':
// It's a text response, so we just display it.
console.log(response.output.generic[0].text);
break;
case 'option':
// It's an option response, so we'll need to show the user
// a list of choices.
console.log(response.output.generic[0].title);
For a dialog webhook, the condition to meet before an action is taken is defined in the dialog skill. If the node condition is not met, then the dialog webhook is never called.

For the message processing webhooks, the condition to check for before taking an action must be defined in the external application code. For example, even if your webhook performs a simple language translation, you'd want to use a condition to check the language of the incoming message before sending the text to the translation service.

You don't need to define a condition for the log webhook unless you want to filter the messages somehow. In most cases, the goal is to write out every message that is submitted, so the messages can be stored for as long as you want, and analyzed by an external application or service.
* Where you configure them

You configure the dialog webhook from the the Options>Webhook page of the dialog skill. You then initialize it from one or more dialog nodes by customizing the node.

You configure the assistant-level webhooks from the Settings>Webhooks page for the assistant.
Making a programmatic call from dialog 

To make a programmatic call, define a webhook that sends a POST request callout to an external application that performs a programmatic function. You can then invoke the webhook from one or more dialog nodes.

A webhook is a mechanism that allows you to call out to an external program based on something happening in your program. When used in a dialog skill, a webhook is triggered when the assistant processes a node that has a webhook enabled. The webhook collects data that you specify or that you collect from the user during the conversation and save in context variables. It sends the data as part of a HTTP POST request to the URL that you specify as part of your webhook definition. The URL that receives the webhook is the listener. It performs a predefined action using the information that you pass to it as specified in the webhook definition, and can optionally return a response.

You can use a webhook to do the following types of things:



* Validate information that you collected from the user.
* Interact with an external web service to get information. For example, you might check on the expected arrival time for a flight from an air traffic service or get a forecast from a weather service.
* Send requests to an external application, such as a restaurant reservation site, to complete a simple transaction on the user's behalf.
* Trigger a SMS notification.
* Trigger a IBM Cloud® Functions web action.



You cannot use a webhook to call a Cloud Functions action that uses token-based Identity and Access Management (IAM) authentication.

For information about how to call a client application, see [Calling a client application from a dialog node](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-dialog-actions-client).



 Defining the webhook 

You can define one webhook URL for a dialog skill, and then call the webhook from one or more dialog nodes.

The programmatic call to the external service must meet these requirements:



* The call must be a POST HTTP request.