Publishing a Message
After you learn the basic concepts in SMN, you can start to create a topic, add subscriptions to the topic, and publish messages on the SMN console or by calling RESTful APIs provided by SMN.
Scenarios
To send similar messages repeatedly, create a message template which contains fixed and changeable content. Every time you send messages using the template, you only have to replace changeable content. For example, your organization holds expositions regularly and needs to notify relevant people of the time, you can create a message template containing date variables and other fixed content.
Step 1. Create a Topic
- Log in to the management console.
- In the upper left corner of the page, click and select the desired region and project.
- Select Simple Message Notification under Application.
The SMN console is displayed.
-
In the navigation pane, choose Topics.
The Topics page is displayed.
- In the upper right corner, click Create Topic.
- Enter a topic name and display name.
Table 1 Parameter descriptions Parameter
Description
Topic Name
Topic name, which:
- Contains only letters, digits, hyphens (-), and underscores (_), and must start with a letter or digit.
- Contains 1 to 255 characters.
- Must be unique and cannot be modified once the topic is created.
Display Name
Message sender name which can contain up to 192 characters
NOTE:After you specify a display name, the sender in email messages will be presented as Display name<username@example.com>. Otherwise, the sender will be username@example.com.
- Click OK.
The topic you created is displayed in the topic list. The system generates a topic URN, which is the unique resource identifier of the topic and cannot be changed.
- Click the name of the topic to view its details, including the topic URN, display name and subscriptions.
Step 2. Add a Subscription
- Log in to the management console.
- In the upper left corner of the page, click and select the desired region and project.
- Select Simple Message Notification under Application.
The SMN console is displayed.
- In the upper right corner, click Add Subscription.
The Add Subscription dialog box is displayed.
- Specify the required subscription information.
- Beside the Topic Name box, click Select Topic.
- Specify the subscription protocol and endpoints.
Table 2 Parameters for adding a subscription Parameter
Description
Topic Name
Specifies the name of the topic to which messages are published.
Protocol
Specifies the protocol over which messages are sent. Possible values include SMS, HTTP, HTTPS, and Email.
Endpoint
Specifies the subscription endpoint. You can add up to 10 SMS, email, HTTP, or HTTPS endpoints, one in each line.
- SMS: Enter one or more valid phone numbers.
The phone number must be preceded by a plus sign (+) and country code.
Examples:
+8600000000000
+8600000000001
- Email: Enter one or more valid email addresses.
Examples:
username@example.com
username2@example.com
- HTTP: Enter one or more public network URLs.
Example:
http://example.com/notification/action
- HTTPS: Enter one or more public network URLs.
Example:
https://example.com/notification/action
- SMS: Enter one or more valid phone numbers.
- Click OK.
The subscription you added is displayed in the subscription list.
- 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. For details, see Traffic Control over Subscription Confirmation.
- 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 your subscription endpoint. You can confirm the subscription within 48 hours through the confirmation link via your mobile phone, mailbox, or other endpoints.
- Subscription confirmation messages will be counted as messages sent and will be billed.
Step 3. Create a Message Template
- Log in to the management console.
- Click on the upper left to select the desired region and project.
- Select Simple Message Notification under Application.
The SMN console is displayed.
- In the navigation pane, choose Message Templates.
- In the upper right corner, click Create Message Template.
The Create Message Template dialog box is displayed.
- Specify the template name, protocol, and content.
Table 3 Parameters required for creating a message template Parameter
Description
Template Name
Template name, which:
- Contains only letters, digits, hyphens (-), and underscores (_), and must start with a letter or digit.
- Can contain 1 to 64 bytes.
- Cannot be modified once the template is created.
Protocol
Endpoint protocol of the template, which cannot be changed once the template is created
The protocol can be Default, SMS, HTTP, HTTPS, or Email.
If you do not specify a protocol, Default is used.
Content
Template content
Use {xxx} as the placeholder to create a template. When you use this template to send 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 (_).
The message template must meet the following requirements:
- The template supports plain text only.
- The template content cannot be left blank and cannot exceed 256 KB.
- The template can contain up to 256 variables in total, but that includes redundant variables. For unique variables, there can be no more than 90.
- When you send messages using a template, the message content you specify for each variable cannot exceed 1 KB.
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.
- Click OK.
The template you created is displayed in the template list.
Step 4. Publish a Template Message
- 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 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.
- Configure the required parameters. (The topic name is provided by default and cannot be changed.)
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 nor exceed 256 KB.
- If you choose to manually type the template message, see Template Message Format for detailed requirements.
- If you choose to automatically generate the template message, proceed with 7 through 10.
- 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. Therefore, all confirmed subscribers in the topic will receive the message content in the default template.
- Click the Preview tab 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..
- Click OK.
The message that is generated contains the template name and variables.
- Click OK.
SMN delivers your message to all subscription endpoints. For details about messages for different protocols, see Messages Using Different Protocols.
Step 5. Receive the Message
- Email
Subscription endpoints are email addresses.
Email messages contain the message subject, content, and a link to unsubscribe.
- HTTP/HTTPS
Subscription endpoints are public network URLs. For details, see section "HTTP/HTTPS Messages" in Simple Message Notification User Guide.
- SMS
Subscription endpoints are phone numbers.
SMS messages contain only the message content.
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