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 the template and set values only for variables without having to edit the message content repeatedly.
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. You can perform the following operations to send notifications:
- Create a topic Mytopic.
- Add SMS and email subscriptions to the topic.
- Publish message The Arts and Crafts Exposition will be held from {startdate} through {enddate}. We sincerely invite you to join us.
{startdate} indicates the date when the exposition is started. {enddate} indicates the date when the exposition is ended.
Operation Process
Figure 1 shows the process to publish a template message.
Step 1. Create a Topic
- Log in to the management console.
- Click on the upper left to select the desired region and project.
- Under Application, select Simple Message Notification.
The SMN console is displayed.
- In the navigation pane, choose Topic Management > Topics.
- In the upper right corner, click Create Topic.
- Set Topic Name to Mytopic.
For details about the parameter requirements, see Creating a Topic.
- 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.
- Click the name of the topic to view its details, including the URN, display name, and subscriptions.
Step 2. Add a Subscription
- In the navigation pane, choose Topic Management > Subscriptions.
- On the Subscriptions page, click Add Subscription.
The Add Subscription dialog box is displayed.
- Add an SMS subscription to a topic.
- Click beside the Topic Name box to select Mytopic.
- Select SMS from the Protocol drop-down list.
- In the Endpoint box, enter the subscription endpoint +8618512345678.
Enter one endpoint on a separate line.
- Click OK.
- Add an email subscription to a topic.
- Click beside the Topic Name box to select Mytopic.
- Select Email from the Protocol drop-down list.
- In the Endpoint box, enter the subscription endpoint username@example.com.
Enter one endpoint on a separate line.
- Click OK.
After a subscription is added, the subscription endpoint receives a confirmation message. Confirm the subscription so that the endpoint can receive messages published to the topic.
- For more details, see Adding a Subscription.
- To prevent malicious users from attacking subscription endpoints, SMN limits the number of confirmation messages that can be sent to an endpoint within a specified period of time. For details, see section "Traffic Control on Subscription Confirmation" in Simple Message Notification User Guide.
- SMN does not check whether subscription endpoints exist when you add subscriptions. However, subscribers will not receive notification messages until they confirm their subscriptions.
- After you add a subscription, SMN sends a confirmation message to the subscription endpoint. The message contains a link for confirming the subscription. The subscription confirmation link is valid within 48 hours. Confirm the subscription on your mobile phone, mailbox, or other endpoints in time.
Step 3. Create a Message Template
- In the navigation pane, choose Topic Management > Message Templates.
- In the upper right corner, click Create Message Template.
The Create Message Template dialog box is displayed.
- In the Create Message Template box, set the following parameters:
- 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.
When you publish the messages, you need to replace {startdate} with the exposition start time and {enddate} with the end time.
- Click OK.
The template you created is displayed in the template list.
Step 4. Publish a Message
- In the navigation pane, choose Topic Management > Topics.
The Topics page is displayed.
- Locate Mytopic and click Publish Message in the Operation column.
- On the Publish Message page, configure the following parameters:
- Topic Name: The topic name is displayed by default.
- Message Format: Template
- Message:
- Click Generate Template Message.
- Select tem_01 from the Template Name drop-down list.
- On the Variables tab, specify startdate and enddate.
For example, set startdate to 02/01/2019 and enddate to 02/10/2019.
For more details, see Publishing a Template Message.
- Click Preview to preview the message.
In this example, the message generated is "The Arts and Crafts Exposition will be held from 02/01/2019 through 02/10/2019. We sincerely invite you to join us.
- Click OK.
The generated message contains the template name and variables.
- Click OK to deliver your message to all subscription endpoints.
For details about messages, see Messages of Different Protocols.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.