A method and device for generating a message

By configuring message attributes and their acquisition methods in the attribute configuration table, the problem of code modification when message template attributes change is solved, the timeliness and efficiency of message generation are improved, and flexible response to changes is achieved.

CN113535163BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010322013.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-22
Publication Date
2024-10-18
Estimated Expiration
2040-04-22

AI Technical Summary

Technical Problem

In the prior art, when the content of the message template changes, the corresponding code needs to be modified to generate a new message, resulting in a reduction in timeliness and an increase in workload in the message generation process.

Method used

Configure multiple second message attributes and their attribute value acquisition methods through the attribute configuration table, generate messages based on these configurations, and only update the attribute configuration table when the message template attributes change to avoid modifying the code corresponding to the message template.

Benefits of technology

It improves the timeliness and generation efficiency of messages, reduces the workload of the message generation process, and enables flexible response to changes in message template attributes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535163B_ABST
    Figure CN113535163B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating a message, and relates to the field of computer technology. A specific implementation of the method includes: determining a message template corresponding to a message to be generated, the message template including at least one first message attribute; determining a method for obtaining a first attribute value of the first message attribute according to a second message attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute, and a method for obtaining an attribute value of the at least one second message attribute; obtaining a first attribute value of the first message attribute according to the method for obtaining the first attribute value; generating the message according to the first attribute value and the message template. This implementation improves the timeliness and efficiency of generating messages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a message. Background Art

[0002] The method of generating messages through message templates is applied in various scenarios, such as using message templates to generate recommendation messages or prompt messages in e-commerce customer service systems.

[0003] The prior art generally generates messages in the following manner: a code corresponding to each message template is generated in advance, and when generating a message, the message is generated by using the code of the message template corresponding to the message to be generated.

[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0005] When the content of a message template changes, such as when a new attribute is added to the message template, the code corresponding to the message template needs to be modified accordingly. The message corresponding to the message template can only be generated after the code is redeveloped and launched. This not only reduces the timeliness of the message, but also increases the workload of the message generation process by modifying the code. Summary of the invention

[0006] In view of this, an embodiment of the present invention provides a method and device for generating a message, wherein a plurality of second message attributes and a method for obtaining their attribute values ​​are configured through an attribute configuration table. When generating a message, the first message attribute value of the first message attribute in the message template can be obtained according to the method for obtaining the attribute in the attribute configuration table, and then the message can be generated by combining the obtained first message attribute and the message template. Thus, by configuring a plurality of second message attributes and a method for obtaining their attribute values ​​through the attribute configuration table, when the attributes of the message template change, such as when a new first message attribute is added to the message template, it is only necessary to increase the second message attribute and a method for obtaining its attribute value in the attribute configuration table accordingly, without changing the code corresponding to the message template, thereby improving the timeliness of the message, reducing the workload of the message generation process, and thus improving the efficiency of generating messages.

[0007] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for generating a message is provided.

[0008] A method for generating a message according to an embodiment of the present invention includes: determining a message template corresponding to a message to be generated, wherein the message template includes at least one first message attribute;

[0009] Determine a method for obtaining a first attribute value of the first message attribute according to a second message attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute and a method for obtaining an attribute value of the at least one second message attribute;

[0010] Obtaining a first attribute value of the first message attribute according to a method for obtaining the first attribute value;

[0011] The message is generated according to the first attribute value and the message template.

[0012] Optionally, when the message template has a newly added attribute, it also includes:

[0013] Determine a method for obtaining the attribute value of the newly added attribute, and update the attribute configuration table according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute; so that the message is generated according to the updated attribute configuration table.

[0014] Optionally, acquiring the first attribute value of the first message attribute according to the method for acquiring the first attribute value includes:

[0015] According to the method for obtaining the first attribute value, respectively generate tasks corresponding to the at least one message attribute;

[0016] The tasks corresponding to the at least one message attribute are executed in parallel, and a first attribute value of the first message attribute is determined according to the execution result of the tasks.

[0017] Optionally, the attribute configuration table further includes: a parsing parameter of an attribute value of the at least one second message attribute; and determining the first attribute value of the first message attribute according to the execution result of the task includes:

[0018] The execution result is parsed according to the parsing parameter corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table to obtain the first attribute value.

[0019] Optionally, the attribute configuration table further includes: an acquisition path corresponding to a method for acquiring an attribute value of the at least one second message attribute; and acquiring a first attribute value of the first message attribute according to the method for acquiring the first attribute value includes:

[0020] The first attribute value is acquired according to an acquisition path corresponding to a second message attribute that is the same as the first message attribute in the attribute configuration table.

[0021] Optionally, generating the message according to the first attribute value and the message template includes:

[0022] For each of the first message attributes: the first attribute value is used to replace the first message attribute, and the message template after the attribute is replaced is used as the message.

[0023] Optionally, the acquisition method includes any one or more of the following: a context parameter acquisition method, a local query method, a remote procedure call method, and an HTTP call method.

[0024] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for generating a message is provided.

[0025] A device for generating a message according to an embodiment of the present invention includes: a first determining module, a second determining module, an acquiring module and a message generating module; wherein:

[0026] The first determining module is used to determine a message template corresponding to the message to be generated, wherein the message template includes at least one first message attribute;

[0027] The second determination module is used to determine a method for obtaining a first attribute value of the first message attribute according to a second attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute and a method for obtaining an attribute value of the at least one second message attribute;

[0028] The acquisition module is used to acquire the first attribute value of the first message attribute according to the acquisition method of the first attribute value;

[0029] The message generation module is used to generate the message according to the first attribute value and the message template.

[0030] Optionally, when the message template has a new attribute,

[0031] The second determination module is also used to determine the method for obtaining the attribute value of the newly added attribute, and update the attribute configuration table according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute; so that the message generation module generates the message according to the updated attribute configuration table.

[0032] Optionally, the acquisition module is used to generate tasks corresponding to the at least one message attribute respectively according to the method for acquiring the first attribute value; execute the tasks corresponding to the at least one message attribute in parallel, and determine the first attribute value of the first message attribute according to the execution results of the tasks.

[0033] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for generating a message is provided.

[0034] An electronic device for generating a message according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for generating a message according to an embodiment of the present invention.

[0035] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.

[0036] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a method for generating a message according to an embodiment of the present invention is implemented.

[0037] One embodiment of the above invention has the following advantages or beneficial effects: by configuring multiple second message attributes and the method for obtaining their attribute values ​​through the attribute configuration table, when generating a message, the first message attribute in the message template is determined, and the attribute value of the first message attribute is obtained according to the method for obtaining the attribute value configured in the attribute configuration table, and then the message can be generated by combining the obtained first message attribute and the message template. Thus, by configuring multiple second message attributes and the method for obtaining their attribute values ​​through the attribute configuration table, when the attributes of the message template change, such as when a new first message attribute is added to the message template, it is only necessary to increase the second message attribute and the method for obtaining its attribute value in the attribute configuration table accordingly, without changing the code corresponding to the message template, thereby improving the timeliness of the message and reducing the workload of the message generation process, thereby improving the efficiency of generating messages.

[0038] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0040] Figure 1 is a schematic diagram of main steps of a method for generating a message according to an embodiment of the present invention;

[0041] Figure 2 is a schematic diagram of main steps of another method for generating a message according to an embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of main steps of another method for generating a message according to an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of main steps of another method for generating a message according to an embodiment of the present invention;

[0044] Figure 5 is a schematic diagram of main modules of a device for generating a message according to an embodiment of the present invention;

[0045] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0046] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0047] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0048] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0049] Figure 1 It is a schematic diagram of main steps of a method for generating a message according to an embodiment of the present invention.

[0050] like Figure 1 As shown, a method for generating a message according to an embodiment of the present invention mainly includes the following steps S101 to S104:

[0051] Step S101: Determine a message template corresponding to a message to be generated, wherein the message template includes at least one first message attribute.

[0052] In various scenarios, messages can be generated by means of message templates. In order to facilitate the generation of messages, message templates corresponding to messages in various scenarios can be pre-configured. The configured message template may include a template name and template content. In order to facilitate the distinction between multiple message templates, message templates may also be stored according to different template IDs. After determining the message to be generated, the corresponding template ID or template name may be determined according to the message content to determine the message template corresponding to the message to be generated and the content of the message template.

[0053] For example, the template of the pre-configured delivery reminder message and the template of the delivery reminder message may be as shown in Table 1 below:

[0054] Table 1

[0055]

[0056]

[0057] After determining the message template corresponding to the message to be generated, the message template can be parsed using a regular expression, and the dynamic attribute parsed out can be used as the first message attribute for the attribute value to be obtained. It can be understood that the first message attribute in the message template is a placeholder that needs to be dynamically replaced in the message template. Taking the template of the delivery reminder message as an example, the first message attribute parsed out is {"orderId", "deliveryDate", "deliveryMan", "deliveryPhone"}. Similarly, the first message attribute that can be parsed out from the template of the delivery reminder message is {"orderId", "deliveryDate"}.

[0058] Step S102: Determine a method for obtaining a first attribute value of the first message attribute according to a second message attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute and a method for obtaining an attribute value of the at least one second message attribute.

[0059] In the attribute configuration table, the method for obtaining the second attribute value of each second message attribute can be configured, wherein the method for obtaining the attribute value can be any one or more of the following: context parameter obtaining method, local query method, remote procedure call method, and HTTP call method. The context parameter obtaining method is to directly obtain the attribute value from the context parameter, the local query method is to obtain the attribute value by querying from the local database, the remote procedure call method is to query the attribute value from the remote database through the remote RPC (Remote Procedure Call) interface, and the HTTP call method is to query the attribute value from the remote database by dynamically calling the remote HTTP interface.

[0060] In the attribute configuration table, the second message attribute can be configured with one or more acquisition methods according to the application situation. In order to facilitate the determination of the second message attribute that is the same as the first message attribute in the message template, the second message attribute can be configured according to the dimension of the message template in the attribute configuration table, that is, the template id or template name is stored in correspondence with the second message attribute and the acquisition method of its attribute value. For example, for the message template of the delivery reminder and the message template of the shipping reminder shown in Table 1, the acquisition method of the corresponding attribute value configured in the attribute configuration table can be shown in Table 2 below:

[0061] Table 2

[0062] Template id Template Name Second message attribute How to get it 1 Delivery Tips orderId context (get context parameters) 1 Delivery Tips deliveryDate db (local query) 1 Delivery Tips deliveryMan RPC (Remote Procedure Call) 1 Delivery Tips deliveryPhone http (http call) 2 Shipping Tips orderId context (get context parameters) 2 Shipping Tips deliveryDate db (local query)

[0063] When the message to be generated is a delivery reminder message, its corresponding message template is a delivery reminder template, and the first message attribute that can be parsed from the message template is {"orderId", "deliveryDate", "deliveryMan", "deliveryPhone"}. Then, from each second message attribute in Table 2, according to the id of the message template or the template name, the second message attribute that is the same as the first message attribute can be determined, and the second message attribute value acquisition method of the determined second message attribute is used as the first attribute value acquisition method of the first message attribute. In this example, according to Table 2, it can be determined that the acquisition method of the first attribute value of the first message attribute "orderId" is the context acquisition method, the acquisition method of the first attribute value of the first message attribute "deliveryDate" is the local query method, the acquisition method of the first attribute value of the first message attribute "deliveryMan" is the remote procedure call method, and the acquisition method of the first attribute value of the first message attribute "deliveryPhone" is the http call method.

[0064] Step S103: Obtain a first attribute value of the first message attribute according to the method for obtaining the first attribute value.

[0065] After determining the method for obtaining the first attribute value, each first attribute value can be obtained according to the corresponding method. Specifically, in one embodiment of the present invention, tasks corresponding to the at least one message attribute can be generated according to the method for obtaining the first attribute value; the tasks corresponding to the at least one message attribute can be executed in parallel, and the first attribute value of the first message attribute can be determined according to the execution results of the tasks.

[0066] In one embodiment of the present invention, the attribute configuration table also includes: parsing parameters of the attribute value of at least one second message attribute; the first attribute value can be determined by: parsing the execution result according to the parsing parameters corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table to obtain the first attribute value.

[0067] When the attribute configuration table includes the parsing parameters of the second attribute value, still taking the message template of the delivery reminder and the message template of the shipping reminder as an example, the attribute configuration table may be as shown in Table 3 below:

[0068] Table 3

[0069] Template id Template Name Second message attribute How to get it Parsing parameters 1 Delivery Tips orderId context (get context parameters) orderId 1 Delivery Tips deliveryDate db (local query) del_date 1 Delivery Tips deliveryMan RPC (Remote Procedure Call) delMan 1 Delivery Tips deliveryPhone http (http call) delPhone 2 Shipping Tips orderId context (get context parameters) orderId 2 Shipping Tips deliveryDate db (local query); del_date

[0070] In an embodiment of the present invention, the acquisition of the first attribute value can be executed by a thread pool. Specifically, after parsing multiple first message attributes from the message template according to a regular expression, the first message attributes can be first stored in a dynamic attribute set List, which can be {"orderId", "deliveryDate", "deliveryMan", "deliveryPhone"}. Then, the dynamic attribute combination List is traversed, and the corresponding tasks are generated according to the acquisition method of the first attribute value of each first message attribute, and the task execution list is encapsulated to generate a task execution set of the first attribute value. The task set is then handed over to the thread pool, so that the thread pool executes the tasks corresponding to each message attribute in parallel. Then, the execution results of each task are obtained through Future, and the execution results are parsed according to the parsing parameters of each first message attribute to obtain the first attribute value, and then each first attribute value is configured in a map, where the first message attribute is the key and its corresponding first attribute value is the value.

[0071] In an embodiment of the present invention, the first attribute values ​​obtained in different ways can be encapsulated into a map according to the parsing parameters corresponding to each first message attribute. For example, through context.get("orderId"), the first attribute value of the first message attribute "orderId" obtained by context parameter acquisition is encapsulated into a map. In addition, for obtaining the first attribute value of the first message attribute "deliveryDate" by local query: execute the sql statement and return it to the map: map.get("dl_date"). For another example, the parameters returned by rpc or http are serialized into json, and the corresponding first attribute value is obtained through json.get("dlMan"), and then the first attribute value is encapsulated into a unified Map.

[0072] Of course, when Future obtains the execution result of each task as the first attribute value, there is no need to use the parsing parameter to parse the execution result, but the execution result of the task can be directly configured in the map.

[0073] According to the above embodiment, Figure 2 As shown, a method for generating a message provided by an embodiment of the present invention may include the following steps S201 to S205:

[0074] Step S201: determine a message template corresponding to a message to be generated, and parse at least one first message attribute from the message template.

[0075] Step S202: Determine, according to a second message attribute in an attribute configuration table that is the same as the first message attribute, an acquisition method and parsing parameters corresponding to a first attribute value of the first message attribute.

[0076] The attribute configuration table includes at least one second message attribute, and an acquisition method and parsing parameters of an attribute value of the at least one second message attribute.

[0077] Step S203: Generate tasks corresponding to the at least one message attribute respectively according to the method for obtaining the first attribute value.

[0078] Step S204: executing the tasks corresponding to the at least one message attribute in parallel, parsing the execution results according to the parsing parameters corresponding to the first attribute value, and obtaining the first attribute value.

[0079] Step S205: Generate the message according to the first attribute value and the message template.

[0080] In addition, in one embodiment of the present invention, the attribute configuration table also includes: an acquisition path corresponding to a method for acquiring the attribute value of at least one second message attribute; the first attribute value can be determined in the following manner: acquiring the first attribute value according to the acquisition path corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table.

[0081] When the attribute configuration table includes the acquisition path of the second attribute value, still taking the message template of the delivery reminder and the message template of the shipping reminder as an example, the attribute configuration table can be shown in Table 4 below. Among them, since the context parameter acquisition method can directly obtain the attribute value from the context parameter, there is no need to configure the corresponding acquisition path. Therefore, the first attribute value can be obtained according to the acquisition path corresponding to each first message attribute.

[0082] Table 4

[0083]

[0084]

[0085] Still taking the generation of a delivery reminder message as an example, the first attribute value of the first message attribute "orderId" can be obtained through the context parameter acquisition method, the first attribute value of the first message attribute "deliveryDate" can be obtained through the acquisition path "Select dl_date from dl_table where order_id={orderId}", the first attribute value of the first message attribute "deliveryMan" can be obtained through the acquisition path "com.jd.dl.DlService:getDlService:{"orderId":"orderId"}", and the first attribute value of the first message attribute "deliveryPhone" can be obtained through the acquisition path "http: / / dl.jd.com / dl / dlservice / getDlInfo?orderId={orderId}".

[0086] Step S104: Generate the message according to the first attribute value and the message template.

[0087] Generally speaking, the first message attribute in the message template is a preset string. When generating a message, the preset string in the message template can be replaced with the obtained first attribute value to generate the message. In one embodiment of the present invention, when generating a message, for each of the first message attributes, the first message attribute can be replaced with the first attribute value, and the message template after the attribute replacement is used as the message.

[0088] After configuring each acquired first attribute value to a map (where the first message attribute is the key and the first attribute value is the value), the List corresponding to the first message attribute can be traversed to replace each first message attribute in the List with the first attribute value in the map. For example, each first message attribute in the List can be replaced by replaceAll.

[0089] Still taking the delivery reminder template as an example, the first message attribute in the List is {"orderId", "deliveryDate", "deliveryMan", "deliveryPhone"}. After obtaining the first attribute value of each first message attribute, the configured map is shown in Table 5 below:

[0090] Table 5

[0091] Key Value orderId 1122334455667788 deliveryDate 20200101 deliveryMan XX deliveryPhone 100000000000

[0092] When generating a message, the string "orderId" in the template is replaced with "1122334455667788", the string "deliveryDate" in the template is replaced with "20200101", the string "deliveryMan" in the template is replaced with "XX", and the string "deliveryPhone" in the template is replaced with "100000000000". After each first message attribute in the message template is replaced by the first attribute value, the generated message is "Your order {1122334455667788}, expected to be delivered on {20200101}; the contact number of the deliveryman {XX} is {100000000000}".

[0093] In addition, the device implementing the message generation method of the embodiment of the present invention can be encapsulated and provide a general interface getTemplateContent(long templateId, Map<String,Object> param), where templateId is the template id, param is the incoming parameter, and the incoming parameter may be the parameter used to obtain the first attribute value through the context parameter acquisition method, that is, when the first attribute value is obtained through the context parameter acquisition method, the first attribute value may be obtained according to the incoming parameter; the incoming parameter may also be the parameter used to replace the first message attribute in the message attribute.

[0094] According to the above embodiment, Figure 3 As shown, a message generation method provided by an embodiment of the present invention may include the following steps:

[0095] Step S301: determine a message template corresponding to a message to be generated, and parse at least one first message attribute from the message template.

[0096] Step S302: Determine the acquisition method corresponding to the first attribute value of the first message attribute according to the second message attribute in the attribute configuration table that is the same as the first message attribute.

[0097] The attribute configuration table includes at least one second message attribute and a method for obtaining an attribute value of the at least one second message attribute.

[0098] Step S303: Obtain a first attribute value of the first message attribute according to the method for obtaining the first attribute value.

[0099] Step S304: for each of the first message attributes: replace the first message attribute with the first attribute value, and use the message template after the attribute is replaced as the message.

[0100] According to the above embodiment, the generation of the message is realized by means of the attribute configuration table. When the message template has a newly added attribute, the method for obtaining the attribute value of the newly added attribute can be determined, and the attribute configuration table can be updated according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute; then, when generating a message corresponding to the message template with the newly added attribute, the message can be generated according to the updated attribute configuration table.

[0101] For example, when the message template of the delivery reminder has a new attribute about the delivery station, the template content at this time can be "Your order {orderId}, expected to be delivered at {deliveryDate}, expected to be stored at {Station}, delivery person {deliveryMan} contact number {deliveryPhone}". At this time, the new attribute of the message template of the delivery reminder is "Station". If it is determined that the method for obtaining the attribute value of the new attribute "Station" is the context parameter acquisition method, the attribute configuration table can be updated according to the method for obtaining the attribute value of the new attribute and its attribute value. Among them, the method for obtaining the attribute value of the new attribute can be determined according to the data storage structure, and can also be determined according to the definition of the configuration personnel. For example, when the attribute value of the new attribute is stored in the local database, the corresponding acquisition method is the local query method. In this example, the attribute configuration table shown in Table 2 can be updated to the attribute configuration table described in Table 6 below according to the method for obtaining the new attribute "Station" and its attribute value:

[0102] Table 6

[0103] Template id Template Name Second message attribute How to get it 1 Delivery Tips orderId context (get context parameters) 1 Delivery Tips deliveryDate db (local query) 1 Delivery Tips deliveryMan RPC (Remote Procedure Call) 1 Delivery Tips deliveryPhone http (http call) 1 Delivery Tips Station context (get context parameters) 2 Shipping Tips orderId context (get context parameters) 2 Shipping Tips deliveryDate db (local query);

[0104] Therefore, when generating a message corresponding to a message template with newly added attributes, the first attribute values ​​of each first message attribute including the newly added attributes can be obtained according to the updated attribute configuration table, and then the first attribute values ​​obtained can be used to replace each first message attribute in the message template to generate a message. This realizes the dynamic acquisition of newly added dynamic attributes in the message template without modifying the code corresponding to the message generation method. In this example, if the first attribute value corresponding to the newly added attribute is obtained as "No. 1 Express Cabinet at the South Gate of YY Community" according to the acquisition method in the attribute configuration table, the generated message is "Your order {1122334455667788} is expected to be delivered on {20200101} and is expected to be stored in {No. 1 Express Cabinet at the South Gate of YY Community}; Deliveryman {XX} Contact Number {100000000000}".

[0105] According to the above embodiment, Figure 4 As shown, a message generation method provided by an embodiment of the present invention may include the following steps:

[0106] Step S401: determine a method for obtaining an attribute value of a newly added attribute in a message template, and update the attribute configuration table according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute.

[0107] Step S402: When the template corresponding to the message to be generated is a message template including a newly added attribute, at least one first message attribute is parsed from the message template.

[0108] It can be understood that the parsed first message attributes include newly added attributes.

[0109] Step S403: Determine a method for acquiring the attribute value of the at least one first message attribute according to the updated attribute configuration table.

[0110] The updated attribute configuration table includes at least one second message attribute, a newly added message attribute, and a method for obtaining the attribute value of the at least one second message attribute and the attribute value of the newly added message attribute.

[0111] Step S404: Obtain a first attribute value of the first message attribute according to the method for obtaining the first attribute value.

[0112] Step S405: for each of the first message attributes: replace the first message attribute with the first attribute value, and use the message template after the attribute is replaced as the message.

[0113] According to a method for generating a message according to an embodiment of the present invention, it can be seen that a plurality of second message attributes and a method for obtaining their attribute values ​​are configured through an attribute configuration table. When generating a message, the first message attribute in the message template is determined, and the attribute value of the first message attribute is obtained according to the method for obtaining the attribute value configured in the attribute configuration table. Then, the message can be generated by combining the obtained first message attribute and the message template. Thus, by configuring a plurality of second message attributes and a method for obtaining their attribute values ​​through an attribute configuration table, when the attributes of the message template change, such as when a new first message attribute is added to the message template, it is only necessary to increase the second message attribute in the attribute configuration table and a method for obtaining its attribute value accordingly, without changing the code corresponding to the message template, thereby improving the timeliness of the message and reducing the workload of the message generation process, thereby improving the efficiency of generating messages.

[0114] Figure 5 4 is a schematic diagram of main modules of an apparatus for generating a message according to an embodiment of the present invention.

[0115] like Figure 5 As shown, the device 500 for generating a message according to the embodiment of the present invention includes: a first determining module 501, a second determining module 502, an acquiring module 503 and a message generating module 504; wherein,

[0116] The first determining module 501 is used to determine a message template corresponding to the message to be generated, wherein the message template includes at least one first message attribute;

[0117] The second determination module 502 is used to determine a method for obtaining a first attribute value of the first message attribute according to a second attribute in an attribute configuration table that is the same as the first message attribute; the attribute configuration table includes at least one second message attribute and a method for obtaining an attribute value of the at least one second message attribute;

[0118] The acquisition module 503 is used to acquire the first attribute value of the first message attribute according to the method for acquiring the first attribute value;

[0119] The message generating module 504 is configured to generate the message according to the first attribute value and the message template.

[0120] In one embodiment of the present invention, when the message template has a new attribute, the second determination module 502 is also used to determine a method for obtaining the attribute value of the new attribute, and update the attribute configuration table according to the new attribute and the method for obtaining the attribute value of the new attribute; so that the message generation module generates the message according to the updated attribute configuration table.

[0121] In one embodiment of the present invention, the acquisition module 503 is used to generate tasks corresponding to the at least one message attribute respectively according to the method for obtaining the first attribute value; execute the tasks corresponding to the at least one message attribute in parallel, and determine the first attribute value of the first message attribute according to the execution results of the tasks.

[0122] In one embodiment of the present invention, the attribute configuration table also includes: parsing parameters of the attribute value of at least one second message attribute; the acquisition module 503 is used to parse the execution result according to the parsing parameters corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table to obtain the first attribute value.

[0123] In one embodiment of the present invention, the attribute configuration table also includes: an acquisition path corresponding to a method for acquiring the attribute value of at least one second message attribute; the acquisition module 503 is used to acquire the first attribute value according to the acquisition path corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table.

[0124] In one embodiment of the present invention, the message generating module 504 is used to replace the first message attribute with the first attribute value for each first message attribute, and use the message template after the attribute is replaced as the message.

[0125] In one embodiment of the present invention, the acquisition method includes any one or more of the following: context parameter acquisition method, local query method, remote procedure call method and HTTP call method.

[0126] It can be seen from the device for generating messages according to the embodiment of the present invention that multiple second message attributes and the method for obtaining their attribute values ​​are configured through the attribute configuration table. When generating a message, the first message attribute in the message template is determined, and the attribute value of the first message attribute is obtained according to the method for obtaining the attribute value configured in the attribute configuration table. Then, the message can be generated by combining the obtained first message attribute and the message template. Thus, multiple second message attributes and the method for obtaining their attribute values ​​are configured through the attribute configuration table. When the attributes of the message template change, such as when a new first message attribute is added to the message template, it is only necessary to increase the second message attribute and the method for obtaining its attribute value in the attribute configuration table accordingly, without changing the code corresponding to the message template, thereby improving the timeliness of the message and reducing the workload of the message generation process, thereby improving the efficiency of generating messages.

[0127] Figure 6 An exemplary system architecture 600 is shown to which the method for generating a message or the apparatus for generating a message according to the embodiments of the present invention can be applied.

[0128] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0129] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0130] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0131] The server 605 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.

[0132] It should be noted that the method for generating a message provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for generating a message is generally arranged in the server 605 .

[0133] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0134] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0135] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0136] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0137] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0138] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0140] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a first determination module, a second determination module, an acquisition module and a message generation module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the message generation module may also be described as "a module for generating a message according to a first attribute value and a message template".

[0141] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: determining a message template corresponding to a message to be generated, the message template including at least one first message attribute; determining a method for obtaining a first attribute value of the first message attribute according to a second message attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute, and a method for obtaining the attribute value of the at least one second message attribute; obtaining the first attribute value of the first message attribute according to the method for obtaining the first attribute value; generating the message according to the first attribute value and the message template.

[0142] According to the technical solution of the embodiment of the present invention, multiple second message attributes and the method for obtaining their attribute values ​​are configured through the attribute configuration table. When generating a message, the first message attribute in the message template is determined, and the attribute value of the first message attribute is obtained according to the method for obtaining the attribute value configured in the attribute configuration table. Then, the message can be generated by combining the obtained first message attribute and the message template. Thus, multiple second message attributes and the method for obtaining their attribute values ​​are configured through the attribute configuration table. When the attributes of the message template change, such as when a new first message attribute is added to the message template, it is only necessary to increase the second message attribute and the method for obtaining its attribute value in the attribute configuration table accordingly, without changing the code corresponding to the message template, thereby improving the timeliness of the message and reducing the workload of the message generation process, thereby improving the efficiency of generating messages.

[0143] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for generating a message, characterized in that: include: Determining a message template corresponding to the message to be generated, the message template comprising at least one first message attribute; Determine, according to a second message attribute in an attribute configuration table that is the same as the first message attribute, a method for obtaining a first attribute value of the first message attribute; the attribute configuration table includes at least one second message attribute, and a method for obtaining an attribute value of the at least one second message attribute; the method for obtaining includes any one or more of the following: a context parameter obtaining method, a local query method, a remote procedure call method, and an HTTP call method; Obtaining a first attribute value of the first message attribute according to a method for obtaining the first attribute value; The message is generated according to the first attribute value and the message template.

2. The method according to claim 1, characterized in that When the message template has a newly added attribute, it also includes: Determine a method for obtaining the attribute value of the newly added attribute, and update the attribute configuration table according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute; so that the message is generated according to the updated attribute configuration table.

3. The method according to claim 1, characterized in that: The acquiring, according to the method for acquiring the first attribute value, the first attribute value of the first message attribute includes: According to the method for obtaining the first attribute value, respectively generate tasks corresponding to the at least one message attribute; The tasks corresponding to the at least one message attribute are executed in parallel, and a first attribute value of the first message attribute is determined according to the execution result of the tasks.

4. The method according to claim 3, characterized in that The attribute configuration table further includes: a parsing parameter of an attribute value of the at least one second message attribute; and determining the first attribute value of the first message attribute according to the execution result of the task includes: The execution result is parsed according to the parsing parameter corresponding to the second message attribute that is the same as the first message attribute in the attribute configuration table to obtain the first attribute value.

5. The method according to claim 1, characterized in that The attribute configuration table further includes: an acquisition path corresponding to a method for acquiring an attribute value of the at least one second message attribute; and acquiring a first attribute value of the first message attribute according to the method for acquiring the first attribute value includes: The first attribute value is acquired according to an acquisition path corresponding to a second message attribute that is the same as the first message attribute in the attribute configuration table.

6. The method according to claim 1, characterized in that The generating the message according to the first attribute value and the message template includes: For each of the first message attributes: the first attribute value is used to replace the first message attribute, and the message template after the attribute is replaced is used as the message.

7. A device for generating a message, characterized in that: include: A first determination module, a second determination module, an acquisition module and a message generation module; wherein, The first determining module is used to determine a message template corresponding to the message to be generated, wherein the message template includes at least one first message attribute; The second determination module is used to determine a method for obtaining a first attribute value of the first message attribute according to a second attribute that is the same as the first message attribute in an attribute configuration table; the attribute configuration table includes at least one second message attribute and a method for obtaining the attribute value of the at least one second message attribute; the method for obtaining includes any one or more of the following: a context parameter obtaining method, a local query method, a remote procedure call method, and an HTTP call method; The acquisition module is used to acquire the first attribute value of the first message attribute according to the acquisition method of the first attribute value; The message generation module is used to generate the message according to the first attribute value and the message template.

8. The device according to claim 7, characterized in that When the message template has new attributes, The second determination module is also used to determine the method for obtaining the attribute value of the newly added attribute, and update the attribute configuration table according to the newly added attribute and the method for obtaining the attribute value of the newly added attribute; so that the message generation module generates the message according to the updated attribute configuration table.

9. The device according to claim 7, characterized in that The acquisition module is used to generate tasks corresponding to the at least one message attribute respectively according to the acquisition method of the first attribute value; execute the tasks corresponding to the at least one message attribute in parallel, and determine the first attribute value of the first message attribute according to the execution results of the tasks.

10. An electronic device for generating a message, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Template obtaining method, template providing method, device and system

    CN104378341A

  • Method and apparatus for processing template data, requesting template data and displaying template data

    CN106534356A