Two Data Messages are arriving at the same time

Hello Cognigy,

we have another situation in our V3 project.
On the Webchat start we are sending two Data Messages to Cognigy.
The Webchat buffers them and then sends both of them at once.

In the Flow there is a Code Node that handles the data and writes it to the Context.
It looks like, that two messages are arriving at the "same time", so that the Code Node is working on the same old context for these two messages.
Can it be or something else if off?


Like this:

Webchat:

webchat.sendMessage("", {A :A});
webchat.sendMessage("", {B : B});

 

Flow:

DefaultContext:
{ "A": "",
"B":""}

CodeNode:
If (ci.data.A) cc.A = ci.data.A
if (ci.data.B) cc.B = ci.data.B

Result in the Webchat (there is a Say node, saying the context):
A = "A"
B=""

A=""
B="B"

Expected:

A = "A"
B= ""

A="A"
B="B"

Thanks,
Anton

Didn't find what you were looking for?

New post
Was this post helpful?
1 out of 1 found this helpful

Comments

4 comments

  • Hey Anton,

    Let me try to help you here. Whenever the Webchat executes the sendMessage() function, the message is sent to the Input object while it can be processed there. In this case, I would recommend using the Context as a persistent data handler since the Input object will be overwritten with every newly sent message from the Webchat.

    So, first check if A and B were sent and are stored in the Context and then display the SAY Node.

     

    Does this help?

     

    Best

    Alex

     

    0
  • Hello Alex,

    sure, the first thing I do is storing the input into the Context.
    See the "CodeNode:..." section in my question above.
    I've also tried the 'actions.addToContext' with the same result.
    I guess we have a problem somewhere else.

    Best,
    Anton

    0
  • Hi Anton,

    I am not sure why you only get one of the two messages processed in your code node. It would be hard to reproduce and may not happen in the current v.4 trial environment, which I am using.

    Can you work around by sending all the data in one message? In your example:

    webchat.sendMessage("", {"A": "A", "B": "B"})

     

    Alternatively, you can intercept the first message in a transformer and remember it in the session storage, then don't send the message to the flow. When the second message arrives, the transformer would pull the first message data from the session storage and add it to the payload, so that it contans data from both messages.

    0
  • Hi Anton,

    yes, sending both messages in one works of course.
    But our setup has to be divided in two parts, so we want to send two separate messages.
    The second message is not mandatory, so I can't wait in the Input Transformer for the second message to arrive.
    I'll test it further and report it here.

    The most simple tests doesn't fail, so the problem is a bit deeper and needs to be treated properly.

    Thanks for your attention.

    Best,
    Anton

     

    0

Please sign in to leave a comment.