Currently I'm exploring the google chat bot and I tried to test the script that I found in google but I encounter an issue, is there someone that encountered same issue as mine?
I still no an idea how to troubleshoot it since this is my first time creating this can someone help me out with this? Thank you in advance.
Error
TypeError: Cannot read property 'space' of undefined
onAddToSpace @ Code.gs:27
Sample script
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 };
}
function onAddToSpace(event) {
var message = "";
if (event.space.singleUserBotDm) {
message = "Thank you for adding me to a DM, " + event.user.displayName + "!";
} else {
message = "Thank you for adding me to " +
(event.space.displayName ? event.space.displayName : "this chat");
}
if (event.message) {
message = message + " and you said: \"" + event.message.text + "\"";
}
return { "text": message };
}
function onRemoveFromSpace(event) {
console.info("Bot removed from ",
(event.space.name ? event.space.name : "this chat"));
}