i am trying to create a bot in google chat and i would like to enter slash commands. it's my first time creating a bot in google chat and i admit i am definitely a beginner. what i managed to do is publish the bot and make it reply to messages, then go added slash commands in the bot configuration panel but i can't integrate its functionality into the bot code. Could someone give me an example? Do you know where I can find useful information? I only found this guide https://developers.google.com/hangouts/chat/how-tos/slash-commands thank you all! edit:
function onMessage(event) {
var name = "";
if (event.space.type == "DM") {
name = "Hai";
} else {
name = event.user.displayName + " ha";
}
if (message.slashCommand) {
switch (message.slashCommand.commandId) {
case 1: // /prova
return { "text": "slash" };
}
}
if (event.message.text =="prova") {
var message = "Prova ok"
} else {
var message = name + " detto \"" + event.message.text + "\"";
}
return { "text": message };
}
/*
Aggiunta bot a conversazione
*/
function onAddToSpace(event) {
var message = "";
if (event.space.singleUserBotDm) {
message = "Bot aggiunto a messaggio diretto, " + event.user.displayName + "!";
} else {
message = "Bot aggiunto in " +
(event.space.displayName ? event.space.displayName : "this chat");
}
if (event.message) {
// Ingaggio su menzione
message = message + " and you said: \"" + event.message.text + "\"";
}
return { "text": message };
}
/*
Messaggio di rimozione bot da conversazione
*/
function onRemoveFromSpace(event) {
console.info("Bot rimosso da ",
(event.space.name ? event.space.name : "this chat"));
}