I want that when I start my system and the Watson chatbot opens, my user_name variable already has the name of the user who has logged in.
onLoad: async (instance) => {
/*Here I get the user name from HTML*/
let userName = document.getElementById("user_name").value || '';
instance.restartConversation();
instance.updateHomeScreenConfig({
is_on: true,
greeting: `Hola ${userName}! Soy tu asistente virtual, dime algo y te ayudo!`
});
instance.send({
input: {
text: ""
},
context: {
global: {
system: {
/*Here is my problem*/
user_name: userName
}
}
}
}).then((eve) => {
console.log("Nombre del usuario enviado al contexto:", userName);
}).catch(err => {
console.error("Error al enviar el nombre al contexto:", err);
});
await instance.render();
}
If it shows me the greeting correctly, but I want my variable to update its value, I already created the variable in Watson, and I also have an intention that tells me what my name is.
That my variable is initialized correctly