12. cxperium-bot-engine’s Main Methods
In this section, we will give information about the main “cxperium-bot-engine” methods, their names, parameters and what they do, which are often used in the source code during the development of the Chatbot process. This information will help developers to develop chatbot applications more effectively and easily. However, the “cxperium-bot-engine” methods are not as limited as described here. For details of the methods described in this section and for information about other methods, you can check the source code of the “cxperium-bot-engine” library.
12.1 transferToLiveRepresentative Method
This method allows the Chatbot process to be transferred to live support. The user can be directed to live support in cases where the user encounters a problem that cannot be solved through Chatbot or needs more help. This method doesn’t take any parameters.
12.2 sendLocationMessage Method
This method is used in the Chatbot process to request a location request from the user. It takes one parameter: Message text to send to the user for location request(string)
12.3 sendListMessageWithSection Method
This method is used to send a segmented list button message in the Chatbot process. It takes five parameters (respectively): Header of the list message (string), Footer information (string), text containing general information about the buttons in the list message (string), the name of the button in the segmented list button (string), an array containing information for each button (array).
12.4 sendLocationRequest Method
This method is used to get the user’s location information during the Chatbot process. It requests the user to request location with a specific message. When the user accepts this request, they share their location with the specified message. It takes one parameter: Text of the message to send to the user for location request (string)
12.5 sendImageMessage Method
This method is used to send a picture message in the Chatbot process. It takes two parameters (respectively): The id of the image to send (string) and the URL of the image to send (string).
12.6 sendImageWithUrl Method
This method is used in the Chatbot process to send an image taken from a URL to the user. It takes two parameters (respectively): The name of the image file to send (string) and the URL of the image to send
12.7 sendDocumentWithUrl Method
This method is used in the Chatbot process to send the user a document retrieved from the URL. It takes two parameters (respectively): The name of the document to send (string) and the URL of the document to send.
12.8 getLocalizationText Method
This method allows to use local expressions defined in CXPerium. It takes one parameter: the id of the local expression to be used (string). Returns the local expression corresponding to the id. That is, it returns the local expression associated with a specific id.
12.9 sendSingleProductMessage Method
This method is used in the Chatbot process to send a message to the user with information about a single product. It takes four parameters (respectively): Text with general information about the product (string), optional footer information (string), catalog id of the product (string), seller id of the product (string).
12.10 sendMultiProductMessage Method
This method is used in the Chatbot process to send a message to the user with information about multiple products. It takes five parameters (respectively): optional header information (string), text with general information about the product (string), optional footer information (string), catalog id of the related product (string), seller id of the related product (string), an array containing information for each product separately (array)
12.11 sendFlowMessage Method
This method is used to send a WhatsApp Flow message to the user during the Chatbot process. It takes eight parameters (respectively): Flow message header information (string), Flow message main content (string), Flow message footer information (string), Flow message token information (string), Flow message id information (string), Flow message CTA information (string), Flow message screen information (string), Flow message required information (object)
12.12 Contact Class ı Methods
In this section, the main methods of the contact class, which can be accessed via “this.services.cxperium.contact” in the source code, will be explained. With the help of these methods, changes can be made to the personal information of the user interacting with the Chatbot process (see also Section 11.7 for information about the “contact” object).
12.12.1 createContact Method
This method is used to create a new user in the Chatbot process. It creates a record containing information such as the user’s phone number, e-mail, profile name and attributes. It takes four parameters (respectively): The user’s phone number (string), The user’s e-mail address (string), The user’s profile name (string), An object to hold the user’s special attributes (attributes).
12.12.2 updateContactConversationDateByContactId Method
This method is used to update the last conversation date for a specific user in the Chatbot process. It has one parameter: A “contactId” of the user (string)
12.12.3 getContactIdByPhone Method
This method is used to access the “contactId” information of the user with the user’s phone number during the Chatbot process. It has one parameter: User’s phone number (string)
12.12.4 getContactByContactId Method
This method is used to access the “contact” object information of the user with the user’s contactId in the Chatbot process. It has one parameter: User’s contactId(string)
12.12.5 anonymizeContact Method
This method is used in the Chatbot process to anonymize a user’s information using a phone number. It has one parameter: User’s phone number (string)
12.12.6 getContactByPhone Method
This method is used to access the “contact” object information of the user with the user’s phone number in the Chatbot process. It has one parameter: User’s phone number (string)
12.12.7 updateContactEmail Method
This method is used to update a user’s email address in the Chatbot process. It has two parameters: ContactId of the user (string) and the new e-mail address to update (string)
12.12.8 updateContactLanguage Method
This method is used in the Chatbot process to update a user’s language preference for a specific contact. It has two parameters: ContactId of the user (string) and the new language preference to update (string)
12.12.9 updateGdprApprovalStatus Method
This method is used to update a user’s KVKK (Personal Data Protection Law) consent status during the Chatbot process. It has two parameters: “contact” object of the user (object) and KVKK approval status information to be updated (boolean)
12.12.10 updateSurveyTransferStatus Method
This method is used to update a user’s survey transfer status in the Chatbot process. It has two parameters: “contact” object of the user (object) and the survey transfer status to update (boolean)
12.12.11 updateLiveTransferStatus Method
This method is used to update the live transfer status of a user in the Chatbot process. It has two parameters: “contact” object of the user (object) and live transfer status information to be updated (boolean)