-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chat-headless: implement agent handoff with support of ChatHttpClient…
… and ChatEventClient (#51) ChatHeadless now accepts a bot chat client and an agent chat client. A Chat client can be of type `ChatHttpClient` (e.g. process requests through Yext Chat API endpoints) or of type `ChatEventClient` (e.g. WebSocket connection for Amazon Connect integration). A chat client can initiate a handoff to the other client. J=CLIP-1286 TEST=manual&auto see that unit tests passed see that the behavior is as expected in test-site with chat-core-aws-connect as the agent client. upon user request, a chat session is created and successfully interact with agent. When agent closes the session, user can either reconnect by sending a new message, or after 15 minutes, resume conversation with the bot.
- Loading branch information
Showing
24 changed files
with
617 additions
and
67 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|
||
The following npm package may be included in this product: | ||
|
||
- @yext/[email protected].0 | ||
- @yext/[email protected].2 | ||
|
||
This package contains the following license and notice below: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/chat-headless/docs/chat-headless.chateventclient.emit.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [emit](./chat-headless.chateventclient.emit.md) | ||
|
||
## ChatEventClient.emit() method | ||
|
||
Emits an event with the specified name and data, triggering all registered listeners for that event. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
emit(eventName: string, data: any): void; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| eventName | string | The name of the event to emit. | | ||
| data | any | The data to be passed to the event listeners. | | ||
|
||
**Returns:** | ||
|
||
void | ||
|
17 changes: 17 additions & 0 deletions
17
packages/chat-headless/docs/chat-headless.chateventclient.getsession.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [getSession](./chat-headless.chateventclient.getsession.md) | ||
|
||
## ChatEventClient.getSession() method | ||
|
||
Provide the current chat session. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
getSession(): any; | ||
``` | ||
**Returns:** | ||
|
||
any | ||
|
24 changes: 24 additions & 0 deletions
24
packages/chat-headless/docs/chat-headless.chateventclient.init.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [init](./chat-headless.chateventclient.init.md) | ||
|
||
## ChatEventClient.init() method | ||
|
||
Initializes the client, using credentials and data in the provided message to setup a chat session. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
init(messageResponse: MessageResponse): Promise<void>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| messageResponse | MessageResponse | The message response that initiated the handoff to the chat client. | | ||
|
||
**Returns:** | ||
|
||
Promise<void> | ||
|
24 changes: 24 additions & 0 deletions
24
packages/chat-headless/docs/chat-headless.chateventclient.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) | ||
|
||
## ChatEventClient interface | ||
|
||
An event-driven client for processing user message and provide responses by emitting and listening to events. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export interface ChatEventClient | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [emit(eventName, data)](./chat-headless.chateventclient.emit.md) | Emits an event with the specified name and data, triggering all registered listeners for that event. | | ||
| [getSession()](./chat-headless.chateventclient.getsession.md) | Provide the current chat session. | | ||
| [init(messageResponse)](./chat-headless.chateventclient.init.md) | Initializes the client, using credentials and data in the provided message to setup a chat session. | | ||
| [on(eventName, cb)](./chat-headless.chateventclient.on.md) | Registers an event listener for a specified event. Supported events are: - <code>message</code>: A new message has been received. - <code>typing</code>: The agent is typing. - <code>close</code>: The chat session has been closed. | | ||
| [processMessage(request)](./chat-headless.chateventclient.processmessage.md) | Processes a message request. The response should be emitted as a message event. | | ||
|
25 changes: 25 additions & 0 deletions
25
packages/chat-headless/docs/chat-headless.chateventclient.on.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [on](./chat-headless.chateventclient.on.md) | ||
|
||
## ChatEventClient.on() method | ||
|
||
Registers an event listener for a specified event. Supported events are: - `message`<!-- -->: A new message has been received. - `typing`<!-- -->: The agent is typing. - `close`<!-- -->: The chat session has been closed. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
on(eventName: "message" | "typing" | "close", cb: (data: any) => void): void; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| eventName | "message" \| "typing" \| "close" | The name of the event to listen to. | | ||
| cb | (data: any) => void | The callback function to be executed when the event is triggered. | | ||
|
||
**Returns:** | ||
|
||
void | ||
|
24 changes: 24 additions & 0 deletions
24
packages/chat-headless/docs/chat-headless.chateventclient.processmessage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [processMessage](./chat-headless.chateventclient.processmessage.md) | ||
|
||
## ChatEventClient.processMessage() method | ||
|
||
Processes a message request. The response should be emitted as a message event. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
processMessage(request: MessageRequest): Promise<void>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| request | MessageRequest | The message request to process. | | ||
|
||
**Returns:** | ||
|
||
Promise<void> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/chat-headless/docs/chat-headless.chathttpclient.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatHttpClient](./chat-headless.chathttpclient.md) | ||
|
||
## ChatHttpClient interface | ||
|
||
An HTTP-based client for processing user messages and generating corresponding responses via a chat service API. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export interface ChatHttpClient | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [getNextMessage(request)](./chat-headless.chathttpclient.getnextmessage.md) | Make a request to generate the next message. | | ||
| [streamNextMessage(request)](./chat-headless.chathttpclient.streamnextmessage.md) | Make a request to generate the next message and stream its tokens via server-sent events. | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.