# Dynamic Messaging

Forwarding dynamic messages is supported starting with the base library {% version (2.4.0)%}.Dynamic messages have the following characteristics compared to regular messages:

  1. After the message is sent, the developer can modify the content of the part of the message through the background interface.
  2. The message has a corresponding alert button. The user can subscribe to the alert by clicking on the alert button. Developers can modify the status of the message in the background and push an alert message to the user who subscribed to the alert

# Message properties

Dynamic messages have status, text content, text color, and system message alerts.

# template

Dynamic messages currently have two templates for use in teams scenarios, which use 'Start' and 'Finish' as status changes and reminders to nodes.

Change and alert nodes Template ID
At the beginning 21B034D08C5615B9889CE362BB957B1EE69A584B
When the time comes, 666F374D69D16C932E45D7E7D9F10CEF6177F5F5

# state

Each template has three states, with their corresponding text content and color. Where state 0 can be transferred to state 0 and 1 and 2, state 1 can be transfered to state 2, state 2 cannot be transferred.

'At the beginning'

state Text content colour The state in which transfer is permitted
0 "A member is joining, the current {member_count} / {room_limit} person" #10AEFF 0, 1, 2
1 "It has begun" #07C160 2
2 "It's over" #CCCCCC nothing

'When the members are all in '

state Text content colour The state in which transfer is permitted
0 "A member is joining, the current {member_count} / {room_limit} person" #10AEFF 0, 1, 2
1 "It's finished." #07C160 2
2 "It's over" #CCCCCC nothing

Keep State 0 without data incoming or State 1 automatically enter State 2 after 24 hours.

# State parameters

Parameters can be carried when each state transfer occurs, and the specific parameters are described below.

parameter type Introductions
member_count string Valid at state 0, the value ofmember_countin the text content template
room_limit string Valid at state 0, the value ofroom_limitin the text content template
path string Status 1 is valid, click "Enter" to start the path used when Weixin Mini Program.For MiniGame, there is no notion of a page that can be used to pass a query character string, such as" ?foo=bar"
version_type string Status 1 is valid, click "Enter" to launch the version used when Weixin Mini Program.Valid parameter values are:develop(development version),trial(experience version),release(official version)

# System Messages

When the user clicks on the card containing the dynamic message to exit Weixin Mini Program the system message is sent, and when the status is transferred the system message content is changed or a new system message is dispatched, as follows.

template content
At the beginning 1.Start, remind me 2. Start, will receive a reminder 3. Started, enter "Weixin Mini Program"
When the time comes, 1.Please remind me when members are all 2. Will be alerted when members are all 3. Members have arrived, enter "Weixin Mini Program"

# How to use it

# I. Create an activity_id

Each dynamic message can be understood as an activity. Before the activity is initiated, the activity needs to be created through the createActivityId interface.activity_id。Theactivity_idis passed in for subsequent forwarding of dynamic messages and updating dynamic messages.

# II. Declare the message type as a dynamic message before forwarding

By calling the wx.updateShareMenu interface, passing inisUpdatableMessage: true, andtemplateInfoactivityIdparameters.WhereinactivityIdis obtained from step 1.

wx.updateShareMenu({
  withShareTicket: true,
  isUpdatableMessage: true,
  activityId: '', // 活动 ID
  templateInfo: {
    parameterList: [{
      name: 'member_count',
      value: '1'
    }, {
      name: 'room_limit',
      value: '3'
    }]
    templateId: '21B034D08C5615B9889CE362BB957B1EE69A584B'
  }
})

# III. Modifying the Content of Dynamic Messaging

After the dynamic message is sent, the message content can be modified by setUpdatableMsg .

# Low version compatible

For client versions that do not support dynamic messages, when a dynamic message is received, it is displayed as a normal message