简体   繁体   中英

Google chat bot Mention user in space

I have a chatbot and I am trying to make the bot mention a user in a space. For example, we have:

@googlechatBot Hello

User said "@googlechatBot Hello"

But I would like you to mention the user in the answer. Something like that

@googlechatBot Hello

@User said "@googlechatBot Hello"

The code I use is from the template found in the documentation.

function onMessage(event) {
  var name = "";

  if (event.space.type == "DM") {
    name = "You";
  } else {
    name = event.user.displayName;
  }
  var message = name + " said \"" + event.message.text + "\"";

  return { "text": message };
}

Did you tried this approach?

{
    "text": "Hey <users/123456789012345678901>! Thank you for using _Pizza bot!_"
}

As described here https://developers.google.com/chat/api/guides/message-formats/basic?hl=en#messages_that_mention_specific_users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM