Skip to content

Commit f728b52

Browse files
committed
v1.0.13
1 parent d52881f commit f728b52

22 files changed

+955
-40
lines changed

API.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ In this documentation, _Web Chat_ refers to the chat widget; _your assistant_ re
2626
- [instance.toggleOpen()](#instancetoggleopen)
2727
- [instance.openWindow()](#instanceopenwindow)
2828
- [instance.closeWindow()](#instanceclosewindow)
29+
- [instance.doAutoScroll()](#instanceDoAutoScroll)
2930
- [instance.destroy()](#instancedestroy)
3031
- [Events](#events)
3132
- [Events summary](#events-summary)
3233
- [Event callbacks](#event-callbacks)
3334
- [Managing Context](#managing-context)
3435
- [Event details](#event-details)
35-
- [pre:send](#presend)
36-
- [send](#send)
37-
- [pre:receive](#prereceive)
38-
- [receive](#receive)
39-
- [error](#error)
40-
- [customResponse](#customresponse)
41-
- [window:open](#windowopen)
42-
- [window:close](#windowclose)
43-
- [Wildcard (*)](#wildcard)
36+
- [`pre:send`](#presend)
37+
- [`send`](#send)
38+
- [`pre:receive`](#prereceive)
39+
- [`receive`](#receive)
40+
- [`error`](#error)
41+
- [`customResponse`](#customresponse)
42+
- [`window:open`](#windowopen)
43+
- [`window:close`](#windowclose)
44+
- [Wildcard (`*`)](#wildcard)
4445

4546
## Key Concepts
4647

@@ -68,16 +69,14 @@ If the last two versions of a browser add up to more than 1% of all web traffic
6869
When you create a Web Chat integration in the Watson Assistant UI, you are given a small embed code to add to your website that looks similar to this example:
6970

7071
```html
71-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
72+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
7273
<script>
7374
const options = {
7475
integrationID: 'YOUR_INTEGRATION_ID', // A UUID like '1d7e34d5-3952-4b86-90eb-7c7232b9b540'
7576
region: 'YOUR_REGION' // 'us-south', 'us-east', 'jp-tok' 'au-syd', 'eu-gb', 'eu-de', etc
7677
};
7778
window.loadWatsonAssistantChat(options).then(function(instance) {
78-
instance.render().then(function() {
79-
console.log('Web Chat has rendered and fetched initial welcome message');
80-
});
79+
instance.render();
8180
});
8281
</script>
8382
```
@@ -109,7 +108,7 @@ The list of customizable variables is short for now, but it will expand signific
109108

110109
**Example**
111110
```html
112-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
111+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
113112
<script>
114113
const options = {
115114
integrationID: 'YOUR_INTEGRATION_ID', // A UUID like '1d7e34d5-3952-4b86-90eb-7c7232b9b540'
@@ -392,6 +391,16 @@ Closes the chat window if it is currently open, and fires the [`window:close`](#
392391
instance.closeWindow();
393392
```
394393

394+
<a name="instance.doAutoScroll"></a>
395+
### instance.doAutoScroll()
396+
Requests the current messages list to auto-scroll to the bottom. The scrolling will scroll to the last set of messages
397+
from either the user or from the bot.
398+
399+
**Example**
400+
```js
401+
instance.doAutoScroll();
402+
```
403+
395404
<a name="instance.destroy"></a>
396405
### instance.destroy()
397406
Destroy the Web Chat widget and return initial content to the DOM. The chat window and chat launcher are both destroyed. All subscriptions to events are removed.
@@ -417,7 +426,7 @@ action that triggered the event stops and no additional event handlers will be c
417426
**Example**
418427

419428
```html
420-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
429+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
421430
<script>
422431
const options = {
423432
integrationID: 'YOUR_INTEGRATION_ID',
@@ -693,4 +702,4 @@ function handler(event) {
693702
console.log(event.type, event.data);
694703
}
695704
instance.on({ type: "*", handler: handler });
696-
```
705+
```

docs/404.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>IBM Watson Assistant Web Chat</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="carbon-components.min.css">
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body class="dark">
10+
<div class="container">
11+
<header aria-label="IBM Platform Name" class="bx--header" role="banner"><a class="bx--header__name" href="index.html"><span
12+
class="bx--header__name--prefix">IBM</span>&nbsp;Watson Assistant Web Chat</a></header>
13+
<div class="hero">
14+
<div class="hero-image-background"></div>
15+
<div class="hero-background"></div>
16+
<div class="homepage--dots"></div>
17+
<div class="hero--content">
18+
<h2>Watson Assistant Web Chat</h2>
19+
<h3>404: The page you are looking for is missing.</h3>
20+
<div class="hero--content--buttons">
21+
<a href="documentation.html" class="bx--btn bx--btn--primary">Documentation</a> <a href="examples.html"
22+
class="bx--btn bx--btn--primary">Examples</a>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
</body>
28+
</html>

docs/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,4 @@
22

33
This folder contains helpful examples to get you started developing with Web Chat.
44

5-
You can view it online (recommended) at https://watson-developer-cloud.github.io/assistant-web-chat/index.html
6-
7-
To run locally:
8-
9-
1. Clone this repo.
10-
2. Navigate to this folder.
11-
3. Run `npm install http-server -g`.
12-
4. Run `http-server ./ -o`.
5+
You can view it online at https://watson-developer-cloud.github.io/assistant-web-chat/index.html

docs/custom-launcher.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
margin-left: -40%;
2828
animation-duration: 0.5s;
2929
transition-duration: 0.5s;
30-
z-index: 4;
30+
z-index: 8000;
3131
}
3232

3333
.chatElement.opening {
@@ -120,7 +120,7 @@
120120
</style>
121121
<script src="libs.js"></script>
122122
<script src="writeTemplate.js"></script>
123-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
123+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
124124
<script>
125125
const options = {
126126
integrationID: 'f38e21ee-d79c-4427-859c-4fdd9bbed8f1',
@@ -212,7 +212,7 @@
212212
}
213213

214214
// Initialize the Web Chat with the default options including your
215-
// integrationsID, region and our updates above to options.element and
215+
// integrationID, region and our updates above to options.element and
216216
// options.showLauncher.
217217
window.loadWatsonAssistantChat(options).then(function(instance){
218218

docs/new-404.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>IBM Watson Assistant Web Chat Documentation</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="carbon-components.min.css">
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body class="dark">
10+
<div class="container">
11+
<header aria-label="IBM Platform Name" class="bx--header" role="banner"><a class="bx--header__name replace" href="https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"><span
12+
class="bx--header__name--prefix">IBM</span>&nbsp;Watson Assistant Web Chat</a></header>
13+
<div class="hero">
14+
<div class="hero-image-background"></div>
15+
<div class="hero-background"></div>
16+
<div class="homepage--dots"></div>
17+
<div class="hero--content">
18+
<h2>Watson Assistant Web Chat</h2>
19+
<h3>The page you are looking for does not exist, click the button below or you will be re-directed in 5 seconds.</h3>
20+
<div class="hero--content--buttons">
21+
<a href="https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"
22+
class="bx--btn bx--btn--primary replace">Web Chat developer documentation.</a>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
<script>
28+
let redirectDomain = "https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"
29+
const currentDomain = window.location.hostname;
30+
if (currentDomain === "pages.github.ibm.com") {
31+
redirectDomain = "https://integrations.us-south.assistant.dev.watson.cloud.ibm.com/web/developer-documentation";
32+
const links = document.querySelectorAll('.replace');
33+
for (let i = 0; i < links.length; i++) {
34+
links[0].setAttribute('href', redirectDomain);
35+
}
36+
}
37+
setTimeout(function() {
38+
window.location.replace(redirectDomain);
39+
}, 5000);
40+
</script>
41+
</body>
42+
</html>

docs/new-index.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>IBM Watson Assistant Web Chat Documentation</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="carbon-components.min.css">
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body class="dark">
10+
<div class="container">
11+
<header aria-label="IBM Platform Name" class="bx--header" role="banner"><a class="bx--header__name replace" href="https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"><span
12+
class="bx--header__name--prefix">IBM</span>&nbsp;Watson Assistant Web Chat</a></header>
13+
<div class="hero">
14+
<div class="hero-image-background"></div>
15+
<div class="hero-background"></div>
16+
<div class="homepage--dots"></div>
17+
<div class="hero--content">
18+
<h2>Watson Assistant Web Chat</h2>
19+
<h3>This page has moved, click the button below or you will be re-directed in 5 seconds.</h3>
20+
<div class="hero--content--buttons">
21+
<a href="https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"
22+
class="bx--btn bx--btn--primary replace">Web Chat developer documentation.</a>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
<script>
28+
let redirectDomain = "https://integrations.us-south.assistant.watson.cloud.ibm.com/web/developer-documentation"
29+
const currentDomain = window.location.hostname;
30+
if (currentDomain === "pages.github.ibm.com") {
31+
redirectDomain = "https://integrations.us-south.assistant.dev.watson.cloud.ibm.com/web/developer-documentation";
32+
const links = document.querySelectorAll('.replace');
33+
for (let i = 0; i < links.length; i++) {
34+
links[0].setAttribute('href', redirectDomain);
35+
}
36+
}
37+
setTimeout(function() {
38+
window.location.replace(redirectDomain);
39+
}, 5000);
40+
</script>
41+
</body>
42+
</html>

docs/public-example-template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<style id="template_styles"></style>
1010
<script src="libs.js"></script>
1111
<script src="writeTemplate.js"></script>
12-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
12+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
1313
<script>
1414
const config = {
1515
integrationID: '',

docs/setting-context.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="style.css">
88
<script src="libs.js"></script>
99
<script src="writeTemplate.js"></script>
10-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
10+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
1111
<script>
1212
const options = {
1313
integrationID: '2bfa63dc-b3d4-4d33-ae14-f9e80f18977f',
@@ -49,7 +49,7 @@
4949
}
5050

5151
// Initialize the Web Chat with the default options including your
52-
// integrationsID and region.
52+
// integrationID and region.
5353
window.loadWatsonAssistantChat(options).then(function(instance){
5454
// Subscribe to the "pre:send" event.
5555
instance.on({ type: "pre:send", handler: preSendhandler });

docs/user-defined-response-types.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="style.css">
88
<script src="libs.js"></script>
99
<script src="writeTemplate.js"></script>
10-
<script src="https://assistant-web.watsonplatform.net/loadWatsonAssistantChat.js"></script>
10+
<script src="https://web-chat.assistant.watson.cloud.ibm.com/loadWatsonAssistantChat.js"></script>
1111
<!-- Bring in the response type handler code -->
1212
<script src="user_defined_templates/carousel.js"></script>
1313
<script src="user_defined_templates/color-box.js"></script>
@@ -96,7 +96,7 @@
9696
}
9797

9898
// Initialize the Web Chat with the default options including your
99-
// integrationsID and region.
99+
// integrationID and region.
100100
window.loadWatsonAssistantChat(options).then(function(instance){
101101
// We won't need this once `user_defined` is a native response type in Watson Assistant.
102102
instance.on({ type: "pre:receive", handler: TEMPORARY_convertToUserDefinedResponse });

docs/user_defined_templates/carousel.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626

2727
.carousel_container.carousel_container_active li.carousel_container_current {
28-
display: block
28+
display: block;
2929
}
3030

3131
.carousel_container .carousel_container_buttons {

0 commit comments

Comments
 (0)