Categories:
directline-rcs-processor plugin
Technical description of directline-rcs-processor plugin
Introduction
This plugin receives requests from aura-groot and send them to RCS callback.
Consumes components (IOC)
| Name | Type | Description |
|---|---|---|
| rcsClient | PluginType.Service | RCS client |
| directlineClient | PluginType.Service | Directline client |
| configurationManager | PluginType.Service | Configuration manager |
| directlineService | PluginType.Service | Services and utilities for Directline channel |
Provides components (IOC)
| Name | Type | Description |
|---|---|---|
| directlineRcsProcessor | PluginType.Processor | Manage RCS responses |
rcs-directline-processor flow definition
To process a message, the directline-rcs-processor uses AuraBridgeFlow with the following definition:
const flow: BridgeFlow = {
name: 'directlineToRcsFlow',
source: {
type: BridgeNodeType.Directline
},
destination: {
type: BridgeNodeType.Rcs,
converter: DirectlineToRcsConverter,
client: services.rcsClient,
clientOptions: { queue: { bridgeFlowName: directlineToRcsFlow.name } }
},
onError: {
destinations: [
{
type: BridgeNodeType.Rcs,
converter: ErrorToRcsApiConverter,
client: services.rcsClient,
decode: RcsDestinationResponseError
},
{
type: BridgeNodeType.Directline,
converter: ErrorToDirectlineEventConverter,
client: services.directlineClient,
decode: RcsDestinationResponseError
}
]
}
};
According to the flow definition, AuraBridgeFlow tries to process, convert and send (using queues) the message to the Google RCS messages endpoint. If some type of error occurs during this process and is marked as recoverable, certain retries will be executed. If after all, the error continues, an error message will be sent to RCS and an error event will be sent to aura-groot.
rcsToDirectlineConverter
Main converter, in charge of transforming DirectLine activities to RCS format.
This converter only handles activities with an attachment type
application/vnd.telefonica.aura.rcs.message with content in RCS format.
{
"type": "message",
"serviceUrl": "http://localhost:8045/aura-services/javiagent",
"channelId": "f7fd1021-41cd-588a-a461-387cc24be225",
"from": {},
"conversation": {
"id": "d152aee9-1aaa-5b54-95a5-79352eee2e45"
},
"recipient": {
"id": "34659949469",
"name": "javiagent_xxxxxx_agent@rbm.goog"
},
"text": "Text doesn't matter",
"inputHint": "acceptingInput",
"attachments": [
{
"contentType": "application/vnd.telefonica.aura.rcs.message",
"content": {
"contentMessage": {
"richCard": {
"carouselCard": {
"cardWidth": "MEDIUM",
"cardContents": [
{
"title": "Card #1",
"description": "The description for card #1",
"suggestions": [
{
"reply": {
"text": "Card #1",
"postbackData": "{\\"intent\\": \\"intent.factotum-test.rcs-formats\\",\\"entities\\":[{\\"type\\":\\"type\\",\\"entity\\":\\"postback\\"},{\\"type\\":\\"data\\",\\"entity\\":\\"card 1\\"}]}"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/cute-dog.jpg",
"forceRefresh": "false"
}
}
},
{
"title": "Card #2",
"description": "The description for card #2",
"suggestions": [
{
"reply": {
"text": "Card #2",
"postbackData": "{\\"intent\\": \\"intent.factotum-test.rcs-formats\\",\\"entities\\":[{\\"type\\":\\"type\\",\\"entity\\":\\"postback\\"},{\\"type\\":\\"data\\",\\"entity\\":\\"card 2\\"}]}"
}
}
],
"media": {
"height": "MEDIUM",
"contentInfo": {
"fileUrl": "https://storage.googleapis.com/kitchen-sink-sample-images/elephant.jpg",
"forceRefresh": "false"
}
}
}
]
}
}
}
}
}
],
"channelData": {
"correlator": "73b72144-7247-4876-880b-57b63efa323e",
"version": "3",
"status": {
"code": "SUCCESS",
"message": "Success"
},
"payload": {
"bridge": {
"channelId": "f7fd1021-41cd-588a-a461-387cc24be225"
}
}
},
"replyToId": "11879060267953086"
}
If an attachment of this type is not present, a simple message with the value of the activity.text field will be sent to the user.