0

We have a bot who is connected via node-sdk (https://www.npmjs.com/package/circuit-sdk) with Circuit. We use the following code

this.addEventListeners = function addEventListeners(client) {
    client.addEventListener('itemAdded', function (evt) {
            client.addTextItem(evt.item.convId, 'answer from bot');
    });
};

but then, the message is not shown under the current topic but as a separate message in the conversation.

Let me explain it with a screenshot:

Screenshot from circuit ui with example dialog

enter image description here

If I open a new topic ("Topic" in my screenshot) with a message ("Hi, this is the first message"), the bot opens a new topic aswell in which it replies to my message ("Answer from Bot (via Websocket)"). How to get it to reply in the topic I opened?

Bharata
  • 13,509
  • 6
  • 36
  • 50
Jo Hö
  • 3
  • 2
  • Hi @JoHo please read https://stackoverflow.com/help/how-to-ask and add some more code in you question, that can help us understand your problem. – BlizZard Aug 23 '18 at 10:25
  • Hi @BlizZard I updated my description, perhaps you can help me now. :-) – Jo Hö Aug 23 '18 at 12:38

1 Answers1

0

You need to pass the id for the thread (parentId) in the addTextItem API. See https://circuitsandbox.net/sdk/classes/Client.html#method_addTextItem.

E.g.

client.addEventListener('itemAdded', function (evt) {
    client.addTextItem(evt.item.convId, {
        content: 'answer from bot',
        parentId: evt.item.itemId
    });
});
Roger Urscheler
  • 774
  • 2
  • 6
  • 11