As announced in the September 30, 2024 news, we've been provided a feature that allows users to mention a bot in group chats on the LINE app. In the Messaging API, we'd like to inform you that a property has been added to the webhook event object sent to the bot server when a user sends a message containing a mention.
This allows bots to recognize when they're mentioned by a user in group chats. If you already have implemented your own process for recognizing mentions to the bot, or if you want to implement a process on your bot server that responds to mentions by users, consider using the new specification for detection.
LINE version 14.17.0 or later for iOS or Android.
The following two specifications has been added with this release:
When a user sends a message that includes a mention, the mention property has been included in the text message object in the webhook event sent to the bot server. With this new specification, when a mention is made of a user or bot, the isSelf property is added to mentionees[] in the mention property.
mention.mentionees.isSelf
Whether the mention is to the bot (destination) that received the webhook event. This is only included when the value of the mention.mentionees[].type property is user.
true: This is a mention to the bot that received the webhook event.false: This is a mention to another user.
If a message sent by a user mentions your bot, the following values will be set in the text message object in the webhook event sent to the bot server:
mention.mentionees[].type will be set to user.mention.mentionees[].userId will be set to the user ID of the bot.mention.mentionees[].isSelf is set to true.
You can check the user ID of the bot in the destination property in the request body of the webhook and in the userId property which can be obtained using the Get bot info endpoint.
The following are examples of the behavior when a user sends a message containing a mention, before and after the addition of the specification:
Users have been able to mention other users in the chat room for some time now. When a user sends a message that includes a mention, a webhook event object containing the following message event was sent to the bot server:
json"message": {
"id": "444573844083572737",
"type": "text",
"quoteToken": "q3Plxr4AgKd...",
"text": "@example Good Morning!!",
"mention": {
"mentionees": [
{
"index": 0,
"length": 8,
"userId": "U49585cd0d5...",
"type": "user"
}
]
}
}
After the specification was added, if there is a mention of a bot in the message sent by a user, a webhook event object containing the following message event will be sent to the bot server. At this time, the isSelf property will be set to true.
json"message": {
"id": "444573844083572737",
"type": "text",
"quoteToken": "q3Plxr4AgKd...",
"text": "@example_bot Good Morning!!",
"mention": {
"mentionees": [
{
"index": 0,
"length": 12,
"userId": "{user ID of the bot}",
"type": "user",
"isSelf": true
}
]
}
}
If a message sent by a user mentions another user, the isSelf property is set to false as follows:
json"message": {
"id": "444573844083572737",
"type": "text",
"quoteToken": "q3Plxr4AgKd...",
"text": "@example Good Morning!!",
"mention": {
"mentionees": [
{
"index": 0,
"length": 8,
"userId": "U49585cd0d5...",
"type": "user",
"isSelf": false
}
]
}
}
The structure of the webhook event object may change, as in the case of this specification addition. Implement your bot server so that it doesn't malfunction when receiving objects with a different structure than before. For more information, see Recommendation for implementation assuming non-breaking feature additions section in the Messaging API documentation.
For more information about the update status of each SDK release related to the above, see the LINE Messaging API SDK release notes.