Start a conversation

Working with Default Autosuggest Mentions

Added in 25.01.

The Autosuggest Mentions feature enables you to retrieve recent users based on the context message or a reply and the current user’s most recent content and followed places. By default, the feature returns five users, but it can be configured. With this response, you can add those mentions to your new message or reply to an existing message.

Permissions

To retrieve the autosuggest members, you must have the following permissions and settings (node-based) enabled.

  • Mention places for places permission
  • Mention content for content permission
  • Mention members for member permission
    Permissions
    Permissions
  • Mention content in posts, Mention places in posts, and Mention members in posts
    Node-Based Settings
    Node-Based Settings

Query the Permissions

To check the permissions using GraphQL, use the below query:

query {
    node(id: "community:DocsCommunity") {
        ... on CoreNode {
            id
            mentionsSettings {
                contentMentionsEnabled {
                    key
                    value
                    localValue
                    invalidReason {
                        key
                        message
                    }
                }
                memberMentionsEnabled {
                    key
                    value
                    localValue
                    invalidReason {
                        key
                        message
                    }
                }
                placesMentionsEnabled {
                    key
                    value
                    localValue
                    invalidReason {
                        key
                        message
                    }
                }
                membersMentionsPerPost {
                    key
                    value
                    localValue
                    invalidReason {
                        key
                        message
                    }
                }
            }
        }
    }
}

The GraphQL response:

{
    "data": {
        "node": {
            "id": "community:DocsCommunity",
            "mentionsSettings": {
                "contentMentionsEnabled": {
                    "key": "mentions.enable_message_mentions",
                    "value": true,
                    "localValue": true,
                    "invalidReason": null
                },
                "memberMentionsEnabled": {
                    "key": "mentions.enable_mentions",
                    "value": true,
                    "localValue": true,
                    "invalidReason": null
                },
                "placesMentionsEnabled": {
                    "key": "mentions.enable_node_mentions",
                    "value": false,
                    "localValue": true,
                    "invalidReason": null
                },
                "membersMentionsPerPost": {
                    "key": "mentions.users_per_message",
                    "value": 50,
                    "localValue": 50,
                    "invalidReason": null
                }
            }
        }
    }
}

Query the Policy Check

To check whether the user can mention the place within a node, use the below GraphQL query:

query {
    node(id: "community:DocsCommunity") {
        ... on CoreNode {
            id
            ... on Community {
                communityPolicies {
                    canMentionNodes {
                        failureReason {
                            message
                        }
                    }
                }
            }
        }
    }
}

If the response returns null, the user has permission to mention the user at any level in a conversation.

The GraphQL response:

{
    "data": {
        "node": {
            "id": "community:DocsCommunity",
            "communityPolicies": {
                "canMentionNodes": {
                    "failureReason": null
                }
            }
        }
    }
}

Set the Place Mention Permission

To set the place mentioned for a node as true, use the below mutation.

mutation {
    setMentionsSettingsOnNode(nodeId: "community:DocsCommunity", settingsInput: {placesMentionsEnabled: true}) {
        result
    }
}

The GraphQL response:

{
    "data": {
        "setMentionsSettingsOnNode": {
            "result": true
        }
    }
}

Retrieve the Default Autosuggest Mention Users

Note: Make sure that the Mention Members and Mention Members in Post are enabled by Admin.

To retrieve the default autosuggest users, use the below GraphQL query:

query {
  defaultUserSuggestions(messageID: "message:593") {
    id
    login
    avatar {
      url
    }
    rank {
      id
    }
  }
}

The GraphQL response:

{
   "data":{
      "defaultUserSuggestions":[
         {
            "id":"user:1",
            "login":"DocAdmin",
            "avatar":{
               "url":"https://docs.community.com/t5/s/docs/images/dS0xLWxYTHhxNA?image-coordinates=87%2C0%2C387%2C300"
            },
            "rank":{
               "id":"rank:2"
            }
         },
         {
            "id":"user:8",
            "login":"DocUser2",
            "avatar":{
               "url":"https://docs.community.com/t5/s/docs/m_assets/avatars/default/avatar-6.svg?time=0"
            },
            "rank":{
               "id":"rank:19"
            }
         }
      ]
   }
}

Significance of Autosuggestion Mentions

You can use the response to:

  • Retrieve a member's data
  • Tag a member to a conversation to respond
  • Create a conversation with the member

Retrieve a Member’s Data

Use the query below to retrieve the auto-suggested member information.

query {
    user(id: "user:8") {
        id
        uid
        title
        login
        email
        firstName
    }
}

The GraphQL response:

{
    "data": {
        "user": {
            "id": "user:2",
            "uid": 1,
            "title": "Occasional Doc user",
            "login": "DocUser2",
            "email": "docuser2@docs.community.com",
            "firstName": "Doe"
        }
    }
}

Create a conversation with a member

Use the below mutation to create a conversation with the member ID.

mutation {
    createForumTopic(createInput: {board: {id: "board:forum1"}, body: "<p>mention <li-user login=\"DocUser2\" uid=\"14\" title=\"Occasional Doc User\" title-override=\"true\"></li-user></p>", subject: "title"}) {
        result {
            id
            uid
            body
        }
    }
}

The GraphQL response:

{
    "data": {
        "createForumTopic": {
            "result": {
                "id": "message:1027",
                "uid": 1027,
                "body": "<P>mention <a href=\"javascript:void(0)\" data-lia-user-mentions=\"\" data-lia-user-uid=\"14\" data-lia-user-login=\"DocUser2\" class=\"lia-mention lia-mention-user\" rel=\"nofollow noopener noreferrer\">DocUser2</a></P>"
            }
        }
    }
}
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. ATLAS

  2. Posted
  3. Updated

Comments