Publishing a Template Message
Scenarios
Message templates contain fixed message content. If you need to send the same or similar messages multiple times, you can create a message template for quick message sending.
You can create different templates for different protocols using the same template name so that each type of subscribers can receive customized messages. Templates contain variables as the placeholders to represent changeable content that you can replace with your own message content. Note that you must create a template whose Protocol is Default, or the system will prevent you from publishing messages using this template name.
When you are creating messages using a template, select a template name. The system will list all variables in the following protocol sequence: Default, SMS, Email, FunctionGraph (function), HTTP, and HTTPS. The same variables are listed only once even if they are used in multiple protocols, and the protocols they support are listed after each variable. Specify content for each variable in the message template, and SMN replaces them with the content you entered. If you do not enter any content for a variable, the system will treat it as empty when sending messages.
SMN tries to match different types of subscribers to the template protocols. If there is no template for a specified protocol, SMN will use the default template to send messages to subscribers of that protocol.
This section describes how to publish messages using a template. For more details about message templates, see Message Template Management.
Prerequisites
Subscribers in the topic must have confirmed the subscription, or they will not be able to receive any messages.
Creating a Message Template
- Log in to the management console.
- Click on the upper left to select the desired region and project.
- Click . Select Simple Message Notification under Management & Governance.
The SMN console is displayed.
- In the navigation pane, choose Topic Management > Message Templates.
- In the upper right corner, click Create Message Template. For details, see Creating a Message Template in Message Template Management.
For example, the template information is as follows:
- Template Name: tem_001
- Protocol: Default
- Content: The Arts and Crafts Exposition will be held from {startdate} through {enddate}. We sincerely invite you to join us.
Figure 1 Creating a message template
Publishing a Template Message
- Log in to the management console.
- Click on the upper left to select the desired region and project.
- Under Management & Governance, select Simple Message Notification.
The SMN console is displayed.
- In the navigation pane, choose Topic Management > Topics.
The Topics page is displayed.
- In the topic list, locate the topic that you need to publish a message to and click Publish Message in the Operation column.
Alternatively, locate the topic and click its name. In the upper right corner of the displayed topic details page, click Publish Message.
- Configure the required parameters. (The topic name is provided by default and cannot be changed. Subject is optional.)
Select Template for Message Format. Then, manually type the template content in the Message box or click Generate Template Message to generate it automatically. The message content cannot be left blank and its size cannot exceed 256 KB.
- Click Generate Template Message.
- Select a template name, for example, tem_001, and enter values for the variables.
The system replaces the variables with the message content you specified. The protocols configured in the template are displayed after each variable. Only the Default protocol is specified in tem_001, as shown in Figure 2. Therefore, all confirmed subscribers in the topic will receive the message content in the default template.
- Click the Preview tab, and click Message Preview to preview the message.
In this example, the message generated is The Arts and Crafts Exposition will be held from February 10 through February 21. We sincerely invite you to join us..Figure 3 Previewing the template message
- Click OK.
The message that is generated contains the template name and variables.Figure 4 Template message example
- (Optional) Configure message attribute parameters. Message attributes specify the scope of message publishing.
Table 1 Message attribute parameters Parameter
Description
Type
Select the type of the message to be published.
- Protocol
- String Array
- String
Name
Enter up to 32 characters, including only digits, lowercase letters, and underscores (_). Start with a number or lowercase letter. Do not end with an underscore (_) or enter consecutive underscores (_).
- When you set Type to Protocol, Name is smn_protocol by default.
- If you set Type to String array, enter the name of the array that restricts the message to be published.
- When you set Type to String, enter the name of the character string that restricts the message to be published.
Value
- When you set Type to Protocol, select a protocol from the drop-down list. The available options are SMS, Email, HTTP, HTTPS, FunctionGraph (function), and functionGraph (workflow).
- When you set Type to String array, enter a string array. Length: 1 to 10
- When you set Type to String, you cannot leave Value blank. Enter up to 32 characters, including only digits, letters, and underscores (_).
- Click OK.
SMN delivers your message to all subscription endpoints. For details about messages for different protocols, see section "Messages of Different Protocols" in Simple Message Notification User Guide.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot