Dialog inverse in integrating watson with the telegram

0

When you start the conversation with Watson the messages appear reversed, you should first say:

  

Hello, Alexandre, I am Jairo!

for just after saying:

  

I am 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);
});

    
asked by anonymous 20.10.2018 / 20:27

0 answers