Search code examples
variablesbotstelegramnode-redwatson-assistant

How to feed Watson Assistant context variable before arriving at Assistant node V2 on node red


Right I integrated Watson Assistant with Telegram using Node Red.

It is working as expected. When sending a message it responds instantly.

So I will be a "$username" variable in the Watson responses and I am not able to assign a value to it (img1).

Img1

as the Watson node receives a paload with the content of the message sent by the telegram (img2), I don't know how to pass the user along.

Img2

And finally Watson returns the answer with one more space as it is expected to receive the variable before going through the Assistant node (img3).

Img

the full flow is here. Now I just need to somehow assign the telegram's first_name to this $user variable

flow

thanks in advance


Solution

  • You add additional context data by adding to msg.additional_context. eg.

    msg.additional_context.user = 'XYZ'
    

    or

    msg.additional_context['user'] = 'XYZ'