Reverse dialogue on Watson’s integration with Telegram

Asked

Viewed 45 times

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

inserir a descrição da imagem aqui

1 answer

-2


Probably the value of the input is coming before the request for a conversation Anova. Try to start passing a "None" value in the message field or not calling the message, only to send the request later. Example: 1° Calls API without message 2° Pass message value

  • Hi, can you give an example of code?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.