DirectLineJS receiving message activity multiplies

I’m using DirectLineJS to comminucate from a custom webchat through a website. I’m using the format posted from Microsoft’s github https://github.com/Microsoft/BotFramework-DirectLineJS

how I have it implemented is

var directLine;
    directLine= new DirectLine.DirectLine({
        secret: "My_DirectLine_Secret",
    });

    function sendReceiveActivity(msg) {
        document.getElementById("inputtext").value = "";
        conversation.innerHTML = conversation.innerHTML + "ME - " + msg + "<br/><br/>";

        directLine.postActivity({
            from: { id: 'myUserId', name: 'myUserName' }, // required (from.name is optional)
            type: 'message',
            text: msg
        }).subscribe(
            id => console.log("Posted activity, assigned ID ", id),
            error => console.log("Error posting activity", error)
            );

        directLine.activity$
            .filter(activity => activity.type === 'message' && activity.from.id === 'mybot')
            .subscribe(
            message => console.log(message)"
            );
    }

whenever I start reading the messages the number of copies increase by one through each message back and forth so the my website will go through this cycle:

Me – send message to bot

BotReply – msg 1

Me – send some message to bot

BotReply – msg 2

BotReply – msg 2

Me – some message

BotReply – msg 3

BotReply – msg 3

BotReply – msg 3

and so on

the response ID I receive from the bot doesn’t increase either for repeated messages so say msg 3 had ID = 00005, each of the BotReply – msg 3 has ID = 00005, but msg 4 would be ID = 00007

In my actual bot I send my messages by using await context.PostAsync("Some mesage");and nothing else

what can I do to reduce the message replies to receive just one?


Source: stackoverflow-javascript