Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,17 @@ A `TockTheme` can be used as a value of a `ThemeProvider` of [`emotion-theming`]
The main source of configuration for the chatbot interface.
Objects implementing this interface can be passed to `renderChat` or to `TockContext`.

| Property name | Type | Description |
|----------------|-------------------------|------------------------------------------------------|
| `locale` | `string?` | Optional user language, as an *RFC 5646* code |
| `localStorage` | `LocalStorageSettings?` | Configuration for use of localStorage by the library |
| `network` | `NetworkSettings?` | If `true`, disables any SSE connection attempt |
| `renderers` | `RendererSettings?` | Configuration for custom image and text renderers |
| Property name | Type | Description |
|----------------|-------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `endpoint` | `string` | The URL of the web connector endpoint |
| `userId` | `(string\|null)?` | Unique user ID. `null` means no clientside ID. `undefined` (default) generates and stores a UUID in the localStorage. |
| `locale` | `string?` | Optional user language, as an *RFC 5646* code |
| `localStorage` | `LocalStorageSettings?` | Configuration for use of localStorage by the library |
| `network` | `NetworkSettings?` | If `true`, disables any SSE connection attempt |
| `renderers` | `RendererSettings?` | Configuration for custom image and text renderers |

> Note: disabling clientside ID is more secure, but requires setting a different [Web Security Mode](https://github.com/theopenconversationkit/tock/tree/master/bot/connector-web#web-security-modes)
> in TOCK Studio.

#### `LocalStorageSettings`

Expand Down
5 changes: 4 additions & 1 deletion src/TockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const TockContext: (props: {
const [state, dispatch] = useReducer(tockReducer, {
quickReplies: [],
messages: [],
userId: retrieveUserId(mergedSettings.localStorage.prefix),
userId:
mergedSettings.userId === undefined
? retrieveUserId(mergedSettings.localStorage.prefix)
: mergedSettings.userId,
loading: false,
sseInitializing: false,
metadata: {},
Expand Down
2 changes: 1 addition & 1 deletion src/TockState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useTockDispatch: () => Dispatch<TockAction> = () => {
export interface TockState {
quickReplies: QuickReply[];
messages: Message[];
userId: string;
userId: string | null;
loading: boolean;
sseInitializing: boolean;
metadata: Record<string, string>;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const Carousel: (props: {
aria-roledescription={
cardRef === undefined
? undefined
: accessibility?.carousel?.slideRoleDescription ?? 'Slide'
: (accessibility?.carousel?.slideRoleDescription ?? 'Slide')
}
>
{cloneElement(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Conversation/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ConversationInnerContainer = styled.ul`
::-webkit-scrollbar {
display: none;
}
`;
`;

const ConversationItemLi = styled.li`
width: 100%;
Expand Down
28 changes: 14 additions & 14 deletions src/model/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export class QuickReply {
imageUrl?: string;

constructor(
label: string,
payload: string,
nlpText?: string,
imageUrl?: string,
label: string,
payload: string,
nlpText?: string,
imageUrl?: string,
) {
this.label = label;
this.payload = payload;
Expand All @@ -24,10 +24,10 @@ export class PostBackButton {
style?: string;

constructor(
label: string,
payload: string,
imageUrl?: string,
style?: string,
label: string,
payload: string,
imageUrl?: string,
style?: string,
) {
this.label = label;
this.payload = payload;
Expand All @@ -45,12 +45,12 @@ export class UrlButton {
style?: string;

constructor(
label: string,
url: string,
imageUrl?: string,
target?: string,
windowFeatures?: string,
style?: string,
label: string,
url: string,
imageUrl?: string,
target?: string,
windowFeatures?: string,
style?: string,
) {
this.label = label;
this.url = url;
Expand Down
4 changes: 2 additions & 2 deletions src/network/TockEventSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class TockEventSource {
* @returns a promise that gets resolved when the connection is open
* and gets rejected if the connection fails or this event source is closed
*/
open(endpoint: string, userId: string): Promise<void> {
const url = `${endpoint}/sse?userid=${userId}`;
open(endpoint: string, userId: string | null): Promise<void> {
const url = `${endpoint}/sse${userId == null ? '' : `?userid=${userId}`}`;
this.onStateChange(EventSource.CONNECTING);
this.currentUrl = url;
return new Promise<void>((resolve, reject): void => {
Expand Down
1 change: 1 addition & 0 deletions src/settings/TockSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface NetworkSettings {

export default interface TockSettings {
endpoint?: string; // will be required in a future release
userId?: string | null;
locale?: string;
localStorage: LocalStorageSettings;
network: NetworkSettings;
Expand Down
Loading