-1
When starting the conversation with Watson the messages appear reversed, first he should say:
Hello, Alexandre, I’m Jairo!
only after saying:
I’m here to remind you [...]
This integration was done using Nodejs.
Code:
[...]
telegramBot.on('message', function (msg) {
// msg = mensagem do usuário
var chatId = msg.chat.id;
context.nome = msg.from.first_name;
conversation.message({
workspace_id: env.workspace_id,
input: {'text': msg.text},
context: context
}, function(err, response) {
if (err)
console.log('error:', err);
else{
context = response.context;
context.nome = msg.from.first_name;
if(response.output.text.length > 0){
response.output.text.forEach(resposta => {
//resposta = resposta do watson
telegramBot.sendMessage(chatId, resposta);
});
}else{
let resposta = response.output.text[0];
telegramBot.sendMessage(chatId, resposta);
}
}
});
});
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});
Hi, can you give an example of code?
– Sergio