diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0a021e7..ca75e2ac7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +* Added a `ViewChat` Intent to be used when a user wants to open an existing chat room. ([#796](https://github.com/finos/FDC3/pull/796)) + ### Changed * Updated definition of the `Instrument` context type to include optional market identifiers ([#819](https://github.com/finos/FDC3/pull/819)) diff --git a/docs/intents/ref/ViewChat.md b/docs/intents/ref/ViewChat.md new file mode 100644 index 000000000..aa35eefdb --- /dev/null +++ b/docs/intents/ref/ViewChat.md @@ -0,0 +1,103 @@ +--- +id: ViewChat +sidebar_label: ViewChat +title: ViewChat +hide_title: true +--- +# `ViewChat` + +Open an existing chat room. + +## Intent Name + +`ViewChat` + +## Display Name + +`View Chat` + +## Possible Contexts + +* [ChatRoom](../../context/ref/ChatRoom) +* [Contact](../../context/ref/Contact): It will open the **direct** chat where there is the current user and the contact +* [ContactList](../../context/ref/ContactList): It will open the **room** where there is the current user and the listed contacts. Contact List may need to display search results if there are multiple matches. + +## Output + +This intent returns as output: +* If the chat doesn't exist, will display a modal to create a chat +* if the chat gets created, return its ChatRoom context +* if none is created return void + +## Example: ChatRoom + +```js +const chatRoom = { + type: 'fdc3.chat.room', + providerName: "Symphony", + id: { + roomId: "j75xqXy25NBOdacUI3FNBH" + } +} + +const intentResolution = await fdc3.raiseIntent('ViewChat', chatRoom); + +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the room was found +``` + +## Example: Contact + +```js +const contact = { + type: 'fdc3.contact', + name: 'Jane Doe', + id: { + email: 'jane@mail.com' + } +} + +const intentResolution = await fdc3.raiseIntent('ViewChat', contact); + +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the direct chat was found +``` + +## Example: ContactList + +```js +const contacts = { + type: 'fdc3.contactList', + contacts: [ + { + type: 'fdc3.contact', + name: 'Jane Doe', + id: { + email: 'jane.doe@mail.com' + } + }, + { + type: 'fdc3.contact', + name: 'John Doe', + id: { + email: 'john.doe@mail.com' + } + }, + ] +} + + +const intentResolution = await fdc3.raiseIntent('ViewChat', contacts); + +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the room was found +``` + +## See Also + +Context + +* [ChatRoom](../../context/ref/ChatRoom) +* [Contact](../../context/ref/Contact) +* [ContactList](../../context/ref/ContactList) + +Intents + +* [StartChat](StartChat) \ No newline at end of file diff --git a/docs/intents/spec.md b/docs/intents/spec.md index 6565d5114..65fd09437 100644 --- a/docs/intents/spec.md +++ b/docs/intents/spec.md @@ -152,6 +152,7 @@ A list of standardized intents are defined in the following pages: * [`StartChat`](ref/StartChat) * [`StartEmail`](ref/StartEmail) * [`ViewAnalysis`](ref/ViewAnalysis) +* [`ViewChat`](ref/ViewChat) * [`ViewChart`](ref/ViewChart) * [`ViewHoldings`](ref/ViewHoldings) * [`ViewInstrument`](ref/ViewInstrument) diff --git a/src/intents/Intents.ts b/src/intents/Intents.ts index 09141c0cb..37faacc51 100644 --- a/src/intents/Intents.ts +++ b/src/intents/Intents.ts @@ -3,6 +3,7 @@ export enum Intents { StartChat = 'StartChat', StartEmail = 'StartEmail', ViewAnalysis = 'ViewAnalysis', + ViewChat = 'ViewChat', ViewChart = 'ViewChart', ViewContact = 'ViewContact', ViewHoldings = 'ViewHoldings', diff --git a/website/sidebars.json b/website/sidebars.json index 2c0a3395e..ef78dbe98 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -42,6 +42,7 @@ "intents/ref/StartChat", "intents/ref/StartEmail", "intents/ref/ViewAnalysis", + "intents/ref/ViewChat", "intents/ref/ViewChart", "intents/ref/ViewHoldings", "intents/ref/ViewInstrument",