Updated on 2024-04-19 GMT+08:00

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

  1. Log in to the management console.
  2. Click on the upper left to select the desired region and project.
  3. Click . Select Simple Message Notification under Management & Governance.

    The SMN console is displayed.

  4. In the navigation pane, choose Topic Management > Message Templates.
  5. 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.

Publishing a Template Message

  1. Log in to the management console.
  2. Click on the upper left to select the desired region and project.
  3. Under Management & Governance, select Simple Message Notification.

    The SMN console is displayed.

  4. In the navigation pane, choose Topic Management > Topics.

    The Topics page is displayed.

  5. 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.

  6. 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" in Simple Message Notification User Guide for detailed requirements.
    • If you choose to automatically generate the template message, proceed with 7 through 10.
  7. Click Generate Template Message.
  8. 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.

  9. 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..

  10. Click OK.

    The message that is generated contains the template name and variables.

  11. (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 (_).
  12. 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.