You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CRM hyperty manages CRM Agents and forwards tickets to available Agents.
3
+
The CRM hyperty manages CRM Agents, forwards tickets to available Agents.
4
+
5
+
It also provides functionalities to support data streams synchronisation setup between Agents and Users without requiring to have both online simultaneously.
4
6
5
7
### Configuration:
6
8
7
-
*`agents`: list of JSON with agent address and associated registration code.
8
9
9
-
`{address: '<agentadddress>',
10
-
code: '<agentcode>'}`
10
+
*`agents`: list of JSON with agent registration codes.
11
+
12
+
`{code: '<agent code>'}`
13
+
11
14
12
15
### Storage
13
16
14
-
The Hyperty handles AgentsPool data collection and associated tickets. The first time the hyperty is executed the collection is initialised based on the `config.agents` info.
17
+
The Hyperty handles the `agents` data collection and associated tickets. The first time the hyperty is executed the collection is initialised based on the `config.agents` info.
18
+
19
+
**Agents Collection**
15
20
16
21
```
17
22
{
18
-
address: <address>,
23
+
address: <url of agent's Group Chat Manager hyperty>,
19
24
code: <code>,
20
25
user: <cguid of the user registered with this agent address>,
21
-
tickets: [{
22
-
user: <cguid of user that created the ticket>
23
-
status: <pending/ongoing/closed>,
24
-
creation: <date>,
25
-
lastModified: <data>,
26
-
message: <received invitation msg>
27
-
}
28
-
}],
26
+
tickets: [<ticketUrl>],
29
27
openedTickets: <int>,
30
28
status: <online/offline>
31
-
32
29
}
33
30
```
34
31
32
+
**Tickets Collection**
33
+
34
+
```
35
+
{
36
+
url: <data object url>,
37
+
user: <cguid of user that created the ticket>,
38
+
status: <new (still not accepted)|pending|ongoing (accepted by agent)/closed>,
39
+
created: <date>,
40
+
lastModified: <data>,
41
+
message: <received invitation msg>,
42
+
agent: <cguid>
43
+
}
44
+
```
45
+
46
+
**pendingSubscriptions data collection**
47
+
48
+
```
49
+
{
50
+
user:<cguid>,
51
+
message: <subscribeMsg>
52
+
}
53
+
```
54
+
55
+
56
+
### resolve-role handler
57
+
58
+
**handlers:** /resolve-role
59
+
60
+
**message:**
61
+
62
+
Message containing agent code.
63
+
64
+
**logic:**
65
+
66
+
It Checks that received `code` is in the `config.agents` array and if there is still no user allocated in the `agents` collection, it returns `role: "agent"`, otherwise returns `role: "user"`.
67
+
35
68
### Agent Registration handler
36
69
37
70
**handlers:** CRM Address.
@@ -42,35 +75,66 @@ Invitation message sent by Wallet Manager to observers.
42
75
43
76
**logic:**
44
77
45
-
It Checks that received `body.code` is in the `config.agents` array and if there is still no user allocated in the AgentsPool, it updates it the new user agent CGUID.
78
+
It Checks that received `body.code` is in the `config.agents` array and if there is still no user allocated in the `agents` collection, it updates it the new user agent CGUID and its address.
46
79
47
80
### New Ticket handlers
48
81
49
-
**handlers:** CRM Address + `/agents`.
82
+
**handler:** CRM Address + `/tickets`.
83
+
84
+
**message:**
85
+
86
+
Standard create message sent to [invite Data Object observers](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#observer-invitation).
87
+
88
+
**logic**
89
+
90
+
It forwards the message to all agents (`msg.to = <agent address>` and `eb.send(<cguid>, msg)` ) and adds the new ticket to the `tickets` collection (status: new).
91
+
92
+
There is a timer to process `new` tickets running every X seconds (eg 300 secs) to change their status to `pending`, in case no agent accepts new tickets ie if `timeNow - createdData > x`.
93
+
94
+
### Update Tickets
95
+
96
+
**handler:** CRM Address + `/tickets`.
50
97
51
98
**message:**
52
99
53
-
Standard create message sent to invite Data Object observers.
100
+
```javascript
101
+
{
102
+
type:"update",
103
+
from:"object url",
104
+
identity:<identity>,
105
+
body: {
106
+
status:"new-participant|closed",
107
+
participant:<hyperty-url>
108
+
}
109
+
}
110
+
```
54
111
55
112
**logic**
56
113
57
-
1- It forwards the message to all agents and add the new ticket to newTickets array.
114
+
`status: "new-participant"`: checks the ticket is still in the `new` or `pending` status and belongs to the user then it executes the `ticketAccepted` function. Otherwise, the message is ignored.
58
115
59
-
2- The first agent executes `ticketAccepted` function: the ticket is allocated to the agent in the agentsPool collection, the ticket is removed from the pendingTickets array and a delete message is sent to all remaining invited Agents (todo: specify this new message that should be similar to delete msg used to remove user from chat).
116
+
**`ticketAccepted` function:** the ticket is associated to the agent, its status changed to `ongoing`and a delete message is sent to all remaining invited Agents. The delete message is similar to this [one](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#delete-data-object-requested-by-reporter):
60
117
61
-
3- In case no agent accepts the ticket, ie a timeout message is received for all invited Agents the message is moved from newTickets array to pendingTickets array.
118
+
```javascript
119
+
"type":"delete",
120
+
"from":"CRM Address",
121
+
"to":"Agente Hyperty URL",
122
+
"body": { "resource":"<ObjectURL>" }
123
+
```
124
+
125
+
`status: "closed"`: Checks if ticket belongs to user, change its status to closed and update collection.
62
126
63
127
### status handler
64
128
65
-
**handler:**<runtime>/status.
129
+
**handler:**CRM Address + `/status`.
66
130
67
131
**message:**
68
132
69
133
Status event message sent by the Vertx Runtime Registry.
70
134
71
135
**logic**
72
136
73
-
For all `live` events received it checks if the CGUID is associated to any agent and forwards to it pending tickets. Execute funtion `ticketAccepted` for 200 ok accepting messages.
137
+
For all `online` events received it checks if the CGUID is associated to any agent and forwards to it pending tickets. Execute funtion `ticketAccepted` for 200 ok accepting messages.
Copy file name to clipboardExpand all lines: docs/offlineSubscriptionManager/readme.md
+46-7Lines changed: 46 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,64 @@ Provides functionalities to support data streams synchronisation setup between p
5
5
6
6
### Storage
7
7
8
-
The Hyperty handles pendingSubscriptions data collection.
8
+
The Hyperty handles two collections:
9
+
10
+
**pendingSubscriptions data collection**
11
+
12
+
```
13
+
{
14
+
user:<cguid>,
15
+
message: <subscribeMsg>
16
+
}
17
+
```
18
+
19
+
**dataObjectsRegistry data collection**
9
20
10
21
```
11
22
{
12
-
<cguid>: {<subscribeMsg>
23
+
user:<cguid>,
24
+
message: <inviteMsg>
13
25
}
14
26
```
15
27
28
+
### Data Object Registration handler
29
+
30
+
**handlers:** <HypertyAddress>/register.
31
+
32
+
**message:**
33
+
34
+
Forward of [Data Object Creation Message](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#hyperty-data-object-creation) message sent by runtime sync manager.
35
+
36
+
**logic:**
37
+
38
+
Stores message at dataObjectsRegistry data collection and it replies with 200 OK.
39
+
40
+
### Data Object Unregistration handler
41
+
42
+
**handlers:** <HypertyAddress>/register.
43
+
44
+
**message:**
45
+
46
+
Forward of [Data Object Delete Message](https://github.com/reTHINK-project/specs/blob/master/messages/data-sync-messages.md#delete-data-object-requested-by-reporter) message sent by runtime sync manager.
47
+
48
+
**logic:**
49
+
50
+
Removes data object message from dataObjectsRegistry data collection and it replies with 200 OK.
51
+
16
52
### Subscription handler
17
53
18
-
**handlers:** Hyperty Address.
54
+
**handlers:** Hyperty Address /subscription.
19
55
20
56
**message:**
21
57
22
-
Forward of [Subscribe](https://rethink-project.github.io/specs/messages/data-sync-messages/#observer-subscription-request-sent-to-data-object-subscription-handler) message sent by runtime sync manager as specified at .
58
+
Forward of [Subscribe](https://rethink-project.github.io/specs/messages/data-sync-messages/#observer-subscription-request-sent-to-data-object-subscription-handler) message sent by runtime sync manager.
23
59
24
60
**logic:**
25
61
26
-
1- It replies with 200 OK.
62
+
1- It queries the Data Objects Registry collection for the data object URL to be subscribed (`message.body.body.resource`), and replies with 200 OK where `reply.body.value = message.body.body.value`.
63
+
27
64
2- Queries the registry about cguid status.
65
+
28
66
3- If online it executes the `processPendingSubscription(subscribeMsg)` otherwise it stores it in the pendingSubscriptions collection.
29
67
30
68
### status handler
@@ -37,9 +75,10 @@ Status event message sent by the Vertx Runtime Registry.
37
75
38
76
**logic**
39
77
40
-
For all `live` events received it checks if the CGUID is associated to any pending subscription and if yes the `processPendingSubscription(subscribeMsg)` function is executed.
78
+
For all `online` events received it checks if the CGUID is associated to any pending subscription at pendingSubscriptions collection and if yes the `processPendingSubscription(subscribeMsg)` function is executed
79
+
41
80
42
81
### `processPendingSubscription(subscribeMsg)`
43
82
44
-
Subscribe message is forwarded to `subscribeMsg.to` and in case a 200 Ok response is received the `subscribeMsg` is removed from pendingSubscription collection.
83
+
Subscribe message is forwarded to `subscribeMsg.to` and in case a 200 Ok response is received it executes the `subscribeMsg` is removed from pendingSubscription collection.
0 commit comments