Dictionaries

The dictionaries are a fundamental part of this project, they are used to store chats in different languages, in this project only English and Spanish are presented.

For each language you add you must generate a new dictionary for that language, the dictionaries can be used in the process file as for example:

let answer = dictionaryModule.documentReceivedResponseSpanish();
let model = models.Text(answer,number);

It can also be used in the processMessage file as shown:

español: processMessageEs.ProcessProductCartSpanish,
english: processMessageEn.ProcessProductCartEnglish

Or they can also be used like this:

let answer = dictionaryModuleEN.englishResponseNameEnglish(namefromDB);
let model = whatsappModelEN.MessageText(answer,number);

The method or the way you want to implement it is up to you.

Why is there a dictionary and a whatsappModules for each language?

Well this question is quite useful, because in early versions the dictionary and the whatsappModules served different purposes.

In this version 2.6 we implemented a couple of changes that allow and facilitate the creation of models in a faster way without having to build the json whenever you want to send a response in whatsappModules.

The dictionaries on the other hand are modules that are normally used to give messages in different languages, these were separated to give a better understanding in the code as well as to simplify it and not to make the code more complex.

For this same reason is that they are placed separately

Summary:

The dictionary of each language contains only text arrays/fields which improves the readability to the code and simplifies it, while in whatsappModules it can contain different types such as links, products, buttons, among others which generates that on one hand text is handled and on the other hand the complexity of each message composed by other attributes is handled.

Última actualización