|
| 1 | +--- |
| 2 | +id: ViewChat |
| 3 | +sidebar_label: ViewChat |
| 4 | +title: ViewChat |
| 5 | +hide_title: true |
| 6 | +--- |
| 7 | +# `ViewChat` |
| 8 | + |
| 9 | +Open an existing chat room. |
| 10 | + |
| 11 | +## Intent Name |
| 12 | + |
| 13 | +`ViewChat` |
| 14 | + |
| 15 | +## Display Name |
| 16 | + |
| 17 | +`View Chat` |
| 18 | + |
| 19 | +## Possible Contexts |
| 20 | + |
| 21 | +* [ChatRoom](../../context/ref/ChatRoom) |
| 22 | +* [Contact](../../context/ref/Contact): It will open the **direct** chat where there is the current user and the contact |
| 23 | +* [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. |
| 24 | + |
| 25 | +## Output |
| 26 | + |
| 27 | +This intent returns as output: |
| 28 | +* If the chat doesn't exist, will display a modal to create a chat |
| 29 | +* if the chat gets created, return its ChatRoom context |
| 30 | +* if none is created return void |
| 31 | + |
| 32 | +## Example: ChatRoom |
| 33 | + |
| 34 | +```js |
| 35 | +const chatRoom = { |
| 36 | + type: 'fdc3.chat.room', |
| 37 | + providerName: "Symphony", |
| 38 | + id: { |
| 39 | + roomId: "j75xqXy25NBOdacUI3FNBH" |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +const intentResolution = await fdc3.raiseIntent('ViewChat', chatRoom); |
| 44 | + |
| 45 | +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the room was found |
| 46 | +``` |
| 47 | + |
| 48 | +## Example: Contact |
| 49 | + |
| 50 | +```js |
| 51 | +const contact = { |
| 52 | + type: 'fdc3.contact', |
| 53 | + name: 'Jane Doe', |
| 54 | + id: { |
| 55 | + email: 'jane@mail.com' |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +const intentResolution = await fdc3.raiseIntent('ViewChat', contact); |
| 60 | + |
| 61 | +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the direct chat was found |
| 62 | +``` |
| 63 | + |
| 64 | +## Example: ContactList |
| 65 | + |
| 66 | +```js |
| 67 | +const contacts = { |
| 68 | + type: 'fdc3.contactList', |
| 69 | + contacts: [ |
| 70 | + { |
| 71 | + type: 'fdc3.contact', |
| 72 | + name: 'Jane Doe', |
| 73 | + id: { |
| 74 | + email: 'jane.doe@mail.com' |
| 75 | + } |
| 76 | + }, |
| 77 | + { |
| 78 | + type: 'fdc3.contact', |
| 79 | + name: 'John Doe', |
| 80 | + id: { |
| 81 | + email: 'john.doe@mail.com' |
| 82 | + } |
| 83 | + }, |
| 84 | + ] |
| 85 | +} |
| 86 | + |
| 87 | + |
| 88 | +const intentResolution = await fdc3.raiseIntent('ViewChat', contacts); |
| 89 | + |
| 90 | +const chatRoom = intentResolution.getResult(): // A chatRoom will be returned as context if the room was found |
| 91 | +``` |
| 92 | + |
| 93 | +## See Also |
| 94 | + |
| 95 | +Context |
| 96 | + |
| 97 | +* [ChatRoom](../../context/ref/ChatRoom) |
| 98 | +* [Contact](../../context/ref/Contact) |
| 99 | +* [ContactList](../../context/ref/ContactList) |
| 100 | + |
| 101 | +Intents |
| 102 | + |
| 103 | +* [StartChat](StartChat) |
0 commit comments