Publishing a Template Message
Scenarios
You can publish a template message to an SMN topic when:
Most of the content in the messages is fixed, and only a few parts vary with the occasions. In this scenario, you can create a message template and use variables as placeholders to indicate changeable content. Each time when you publish a message, you can select a template and set values only for variables without having to edit the message content repeatedly.
This topic describes how to create a topic and publish a template message.
For example, your organization holds expositions regularly, and you need to notify people of the time. Except for the time, most part of the message remains unchanged.
Operation Process
Procedure |
Description |
---|---|
Sign up for a HUAWEI ID, complete real-name authentication, enable Huawei Cloud services, and top up your account. |
|
Create a topic Mytopic. |
|
Add SMS and email subscriptions to the topic. |
|
Create a message template named tem_001 and select Default, SMS, and Email for Protocol separately. |
|
Publish a message to SMS and email endpoints: The Arts and Crafts Exposition will be held from {startdate} through {enddate}. We sincerely invite you to join us. {startdate} indicates when the exposition will be started. {enddate} indicates when the exposition will be ended. |
|
The subscription endpoints receive the message. |
Making Preparations
- Sign up for Huawei Cloud and complete real-name authentication.
Before using SMN, sign up for a HUAWEI ID, enable Huawei Cloud services, and complete real-name authentication.
If you have enabled Huawei Cloud services and completed real-name authentication, skip this step.
- Top up your account.
Ensure that the account balance is sufficient. If not, top up your account.
Step 1: Create a Topic
- Log in to the SMN console and go to the Create Topic page.
- Configure topic parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.Figure 1 Create Topic
Table 1 Parameters for creating a topic Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic to be created.
Enterprise Project
default
This parameter is displayed only for enterprise users who have enabled enterprise project management.
- Click OK.
After a topic is created, the system generates a topic URN, which uniquely identifies the topic and cannot be changed. The topic you created is displayed in the topic list.
- In the topic list, locate Mytopic and click Add Subscription in the Operation column.
- Configure subscription parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.
Figure 2 Add Subscription
Table 2 Parameters for adding an SMS subscription Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to add subscriptions.
Protocol
SMS
Select SMS from the Protocol drop-down list.
For more supported protocols, see What Protocols Does SMN Support?
Endpoint
+8618612345678
Enter a valid mobile number in the text box.
- You can enter up to 10 endpoints, each on a separate line.
- SMN does not check whether subscription endpoints exist when you add subscriptions.
- Click OK.
After a subscription is added, the subscription endpoint receives a confirmation message. The recipient needs to click the subscription confirmation link on the subscription endpoint to confirm that they agree to receive messages published to the topic. On the SMN console, you can see that the subscription status is Confirmed.
- In the topic list, locate Mytopic and click Add Subscription in the Operation column.
- Configure subscription parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.
Figure 3 Add Subscription
Table 3 Parameters for adding an email subscription Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to add subscriptions.
Protocol
Email
Select Email from the Protocol drop-down list.
For more supported protocols, see What Protocols Does SMN Support?
Endpoint
username@example.com
Enter a valid email address in the text box.
- You can enter up to 10 endpoints, each on a separate line.
- SMN does not check whether subscription endpoints exist when you add subscriptions.
- Click OK.
After a subscription is added, the subscription endpoint receives a confirmation message. The recipient needs to click the subscription confirmation link on the subscription endpoint to confirm that they agree to receive messages published to the topic. On the SMN console, you can see that the subscription status is Confirmed.
Step 3: Create a Message Template
- In the navigation pane on the left, choose Topic Management > Message Templates.
- On the displayed page, click Create Message Template in the upper right corner.
- Configure message template parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Message Template Management.
Figure 4 Create Message Template
Table 4 Parameters for creating a message template Parameter
Example Value
Description
Template Name
tem_001
Specifies the name of the template to be created.
Protocol
- Default
- SMS
Create a message template named tem_001 and select Default, SMS, and Email separately.
Content
The Arts and Crafts Exposition will be held from {startdate} through {enddate}. We sincerely invite you to join us.
Customize the template content.
Use {xxx} as the placeholder to create a template. When you use this template to publish messages, replace {xxx} with specific content. xxx must start with a letter or digit and can contain up to 21 characters, including only letters, digits, hyphens (-), periods (.), and underscores (_).
- Click OK.
The template you created is displayed in the template list.
Step 4: Publish a Message
- In the navigation pane on the left, choose Topic Management > Topics.
- Locate Mytopic and click Publish Message in the Operation column.
Figure 5 Publish Message
Table 5 Parameters for publishing a message Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to publish a message.
Message Format
Template
Specifies in which format messages will be sent.
Message
{ "message_template_name": "tem_001", "tags": { "startdate": "08/02/2024", "enddate": "08/20/2024" } }
You can manually enter a template message or click Generate template Message to automatically generate a message.
For details, see Template Message Format.
- Click OK.
For details about messages, see Messages Using Different Protocols.
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