How to create a User Feed using the modules Message and Flag? What I'm trying to do is in theory easy : **User** flagged **Article**. But I'm having hard time figuring out how to build a user feed like this with Message and Flag modules.

I looked a little bit at the Message UI to create a message type, but can't seem to find a "Flagging user" token. The only related flag token I've found is Users who flagged the entity with flag flag which prints all users that liked an article like this:

User A, User B, User C flagged Article 

What I really need is to print a message for every flag, like this: 


User A flagged Article
User B flagged Article


And finally show everything in a view to the Article author.

Any suggestions?
If you'd add the Rules module (on top of the Message and Flag module you're already using), you can get this to work by using the "Replacement tokens" as part of your "Message type" configuration.

If you're not familiar with these Replacement tokens, you can learn about it the answer to What's the purpose of "Replacement tokens" of a Message type? This answer also includes a sample rule which is similar to what you'll need: it makes the value of token flagging-user available to the Message type.

Some more details to resolve this specific question here:


Add a Replacement token in your Message type, and call it (say) @user_who_flagged (or %user_who_flagged if you prefer).
Use that @user_who_flagged (or %user_who_flagged) token anywhere you want in the message you're trying to produce.
Have Rules create your message (of the message type you're using), which you can do like so:


Rules Event "Article gets flagged".
Rules Action "Create an entity" (corresponding to your Message type, and use a variable like (say) entity_created for that).

Add an appropriate Rules Action to pass the value of the "Replacement token" (which is used in the Message type as detailed above):


which looks like entity-created:arguments:user-who-flagged, and
in which you pass the value flagging-user (that's the clue to make it work ...).

Should you want to include additional info in your message about the actual Article (like nid, content type, title, author, whatever), then just create an additional Replacement token for each of them, and a similar Rules Action for each of them also.


With the above approach you'll have your messages created with the custom content you want. Those messages are Drupal entities, so creating an appropriate view from it is straight forward.

For anybody not familiar with the (great) Message module yet (which is poorly dcumented ...), here is your chance to get a first impression about it ... Below is an export of "a" message type that you could use to get started (by simply importing it in your own site). It actually works together with the example rule in the related question. This message type has machine name user_following, and uses a replacement token like @following_user (adapt both to fit your needs, eg change @following_user to @user_who_flagged to use what I suggested above):

{
  "name" : "user_following",
  "description" : "User following",
  "argument_keys" : [ "@following_user" ],
  "argument" : [],
  "category" : "message_type",
  "data" : {
    "token options" : { "clear" : 0 },
    "purge" : { "override" : 0, "enabled" : 0, "quota" : "", "days" : "" }
  },
  "language" : "",
  "arguments" : null,
  "message_text" : { "und" : [
      {
        "value" : "@following_user started following [message:user:name]",
        "format" : "plain_text",
        "safe_value" : "\u003Cp\u003E@following_user started following [message:user:name]\u003C\/p\u003E\n"
      }
    ]
  },
  "rdf_mapping" : []
}


Notes:


(to avoid confusion) [message:user:name] in the message type sample above is the user to which the message is targeted, not the flagging user!
(if you still don't get the clue of all this) using Rules it's possible to make data originating from any module (such as the Flag module) available as tokens to the Message module.