Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Orchestrator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Orchestrator

The orchestrator authenticates & processes the user data from whom the message is received. The XMessage will then be pushed to the Kafka topic, the transformer will listen to this topic to further process it.

## 1. Authentication

Orchestrator receives User Data in the form of XMessage and authenticates the user via FusionAuth Service.\
FusionAuth help to manage the following data :

- authentication - who is this user?
- authorization - what can this user do?

## 2. Conversion between `from` and `to`

XMessage contains data about the **from** where the message is coming and **to** where it should be delivered.

In case when a message is coming from the user-end, it should come `from: User` and `to: Bot`, but in case of response from bot, it should come `from: Bot` and `to: User`.

this conversion between **to** and **from** is done in the orchestrator after authentication.

## 3. Push to Kafka topic

Now after _authentication_ and conversion between _from_ & _to_ Orchestrator push this XMessage to the Kafka topic and the transformer will listen to this topic to further process it.
31 changes: 31 additions & 0 deletions SourceCode_Docs/Adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Adapter

Adapters convert information provided by channels (SMS, Whatsapp) for each specific provider to XMessages and vice versa. Adapters are the gateway to the external services and are responsible for receiving user response and sending the response to users.

## 1. Netcore Whatsapp Adapter

`NetcoreWhatsappAdapter` class is used to convert API/Webhook data received from Netcore Service into XMessage Formate.\
this class uses the following methods for conversion:

- **convertMessageToXMsg**: Used in Inbound to convert API/Webhook data provided by Netcore into XMessage.

- **processOutBoundMessageF**: Used in Outbound to convert XMessage back to Netcore API/Webhook data.

## 2. GupShup Whatsapp Adapter

`GupShupWhatsappAdapter` class is used to convert API/Webhook data received from GupShup Service into XMessage Formate.\
this class uses the following methods for conversion:

- **convertMessageToXMsg**: Used in Inbound to convert API/Webhook data provided by GupShup into XMessage.

- **processOutBoundMessageF**: Used in Outbound to convert XMessage back to GupShup API/Webhook data.

## 3. Sunbird Web Portal Adapter

`SunbirdWebPortalAdapter` class is used to convert API/Webhook data received from Netcore Service into XMessage Formate.\
this class uses the following methods for conversion:

- **convertMessageToXMsg**: Used in Inbound to convert API/Webhook data provided by Sunbird Web Service into XMessage.

- **processOutBoundMessageF**: Used in Outbound to convert XMessage back to Sunbird API/Webhook data.

34 changes: 34 additions & 0 deletions SourceCode_Docs/Dao.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dao
Dao holds the dao & repository classes for XMessage.

## 1. XMessageDAO

XMessageDAO is basically dao structure for XMessage. It contains all the field of XMessage which will be stored in the database.\
The fields include :

- **id**: Auto generated ID for each XMessage to identify and distinguish each XMessage on database.

- **userId**: Refers to Unique User ID which will be used to authenticate user.

- **fromId** : Refers to the Unique form which contain Conversation Logic for current message.

- **channel**: Describe the channel from where message is coming (eg: WhatsApp / Telegram / SMS).

- **provider**: Describe the service provider being used for sending / receving messages from channel.

- **timestamp**: Time when the message was sent/generated.
- messageState

- **xMessage**: XMessage Payload converted in String format.

- **messageId**: Message ID is unique Key comes along with each message to identify and distinguish all messages.

- other than these XMessageDAO have more fields which include : app, auxData, replyId, causeId.

## 2. XMessageRepository

XMessageRepository contains all the data retrival queries for XMessageDAO. We use these methods to get desirable data from database, via diffrent parameters.

## 3. XMessageDAOUtils

XMessageDAOUtils is a util class to filter-out data of XMessage acording to XMessageDAO and store it on database.
15 changes: 15 additions & 0 deletions SourceCode_Docs/Inbound.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Inbound

Inbound receives the messages from a channel, and uses the channel adapter to convert it to XMessage format. Once the message is converted, it will be pushed to the kafka topic, the orchestrator will listen to this topic to further process it.

## 1. Netcore Whatsapp Converter

- `NetcoreWhatsappConverter` class accept incoming data from WhatsApp in Netcore Webhook/API data.
- this data is sent to `XMsgProcessingUtil` class to process further checks and validations.
- `XMsgProcessingUtil` class use `NetcoreWhatsappAdapter` to convert Webhook/API data into XMessage format.

## 2. GupShup Whatsapp Converter

- `GupShupWhatsappConverter` class accept incoming data from WhatsApp in GupShup Webhook/API data.
- this data is sent to `XMsgProcessingUtil` class to process further checks and validations.
- `XMsgProcessingUtil` class use `GupShupWhatsappAdapter` to convert Webhook/API data into XMessage format.
46 changes: 46 additions & 0 deletions SourceCode_Docs/Message-Rosa.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Message-Rosa

Message Rosa holds all the core models for XMessage & its property fields.

## 1. XMessage

XMessage is a standard defined for the UCI ecosystem. The key objective of this is to make the internal functioning of UCI, independent of external factors viz. Communication channel and service provider.\
XMessage class in Message-Rosa majorly focuses on the following properties :

- **messageId**: Message-ID is a unique Key that comes along with each message to identify and distinguish all messages.

- **payload**: Payload contains all the message data which is separatly defined in [XMessage Payload](#2-xmessage-payload).

- **messageType**: This is enum which describe the type of message from one of (broadcast_text / text / hsm_with_button / hsm).

- **to - from**: These stores the information of sender and receiver that from where the message is coming and to where it needs to deliver.

- **channelURI**: Describe the channel from where message is coming (eg: WhatsApp / Telegram / SMS).

- **providerURI**: Describe the service provider being used for sending/receiving messages from the channel.

- **adapterId**: Refers to Adapter-ID used to convert from API/webhook data to XMessage, so with the same adapter the response XMessage would be changing in the original API/webhook data.

- **transformers**: contains the reference of transformers to be used for processing XMessage and generating the response.

- other than these major properties, XMessage have more properties which include: app, timestamp, userState, encryptionProtocol, messageState, lastMessageID, conversationStage, conversationLevel, thread, marshaller, context.


## 2. XMessage Payload

XMessagePayload is the body of a message, which contains all the data inside of a message.\
XMessagePayload has the following properties :

- **text**: contains text attached with the message.

- **stylingTag**: useful to indicate that message contains any media or list/button view.

- **media**: contains media data attached with the message, it will be _null_ if not applicable.

- **mediaCaption**: Caption to be attached with media, it will be _null_ if not applicable.

- **location**: contains location data attached with the message, it will _null_ if not applicable.

- **buttonChoices**: useful for sending a response with button choices, it will _null_ if not applicable.

- other than these XMessagePayload has more properties which include: flow, questionIndex, contactCard.
3 changes: 3 additions & 0 deletions SourceCode_Docs/Orchestrator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Orchestrator

The orchestrator authenticates & processes the user data from whom the message is received. The XMessage will then be pushed to the Kafka topic, the transformer will listen to this topic to further process it.
7 changes: 7 additions & 0 deletions SourceCode_Docs/Outbound.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Outbound

Outbound converts the xMessage to the one that will be sent to the channel(sms/whatsapp). It will then be sent to the network provider(Netcore/Gupshup) who will send it to the channel.

For this Outbound uses `OutboundKafkaController` class which listen from kafka topic through `reactiveKafkaReceiver` and receive XMessage Response generated from Transformer.\
Now this XMessage is converted back to Webhook/API data via relevent adapter and sent to network provider (Netcore/GupShup)

4 changes: 4 additions & 0 deletions SourceCode_Docs/Transformer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Tranformer

Transformers transforms the previous xMessage from the user to one that needs to be sent next. It is a microservice that returns a new xMessage based on the previous user action, which will then be shown to the user. The XMessage will be pushed to the kafka topic, the outbound will listen to this topic to further process it.

51 changes: 51 additions & 0 deletions SourceCode_Docs/Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Utils

Utils communicate with the federation service via APIs. It holds all the utility/helper classes which will be used in other repositories.

## 1. Campaign Service

`Campaign` class contains methods for retrieving campaign data via different parameters :

- getCampaignFromID
- getCampaignFromNameTransformer
- getFirstFormByBotID
- getBotNameByBotID
- getCampaignFromNameESamwad


## 2. Bot Service

`BotService` class contains methods for retrieving bot and campaign data via different parameters :

- getBotFromStartingMessage
- getBotFromName
- getCampaignFromStartingMessage
- getCampaignFromName


## 3. Simple Kafka Producer

`SimpleProducer` class contains a method for sending data to Kafka topic.\
we use the `send` method from this class to send XMessages on different Kafka topics.

## 4. Azure Blob Service

`AzureBlobService` class contains methods for uploading and retrieving files from **Azure Blob Storage**.

- uploadFile
- uploadFileFromInputStream
- getFile
- getFileSignedUrl

## 5. User Service

`UserService` class contains methods for retrieving User data via different parameters :

- findByEmail
- findByPhone
- findByPhoneAndCampaign
- getUsersFromFederatedServers
- getUserByFullName
- findUsersForCampaign
- findUsersForGroup