I tried to connect watson assistant to telegram an i can't fix this error
msg.payload.output.text does not exist. Feed the telegram node into a debug node to see what is there.
I tried to connect debug node to watson assistant node and get the correct respond , But i want to send this respond to telegram , Can you please give me the correct code to send the respond from watson assistant node to telegram sender node through function node
what is the correct code to write it into function node
Show us the data you are getting and tell us the format you want out.
What exactly do you want out of the function node, or is the problem that you don't know?
i want the code in the function that connected to telegram sender node
( Prepare for telegram ) function node
Yes, you keep saying that, but to write the code in the function node it is necessary to know exactly what form you want the data. You have shown us the input data, so for that input data what data structure do you want out of the function?
I don't Understand you
it's a simple chatbot the get message from telegram user in send it to watson assistant and get respond to send it back
sorry again for my little coding experience
i followed this Tutorial
Im pretty sure from limited information the screenshots provide that your path to the text that you use in the function is wrong.
Click on the left icon when you hover over the path property in the debug tab to copy the path to the text property:
Im pretty sure its not going to be
But as I just saw from the screenshots I think this will not help you much either as it looks like not every object in the
generic array has a text property and the text property isn’t at the same index in the array either everytime.
I think you will have a lot of reading to do.
What you will have to do is something like this:
- iterate over the
msg.output.genericarray with something like
- than in the
forEach()check if the
response_typeproperty of the index is
- if it is
textuse your function code from above adapted to work for the index within the
forEach()loop and send a msg using the async node.send() provided by the function node instead of
Thats just a very rough sketch of what I think your function node will have to do to make it work in the end.
The code from your linked tutorial is not working as you are receiving the message in a different format from the Watson node as it probably was when the tutorial was written. The Tutorial is 2 years old so things have probably just changed since than. The error your seeing is because of that. So you will need to adapt it as described above.
Can you please write this code for me
i have little coding experience and i can't write it myself
Not really as I use neither Watson nor Telegram from Nodered. I can give you the tools you need to learn how to do it yourself. Why don’t start by reading the things I linked above and than you give it go and come back when you’re stuck and we‘ll go through it bit by bit if necessary.
ok give me this tools and i'll try to do it myself
It’s what I wrote above in Edit 1:
- So use the way i show in the screenshot to copy the path to the
genericarray in your
- Read on how to use
forEach()in the link above and apply that to the generic array which path you have found.
- In the function that
forEach()executes on each array index check if the index is text with a simple if condition.
- If the yes build your new message object same as you did in the function you posted above from the tutorial but use the async
node.send()as described above in the link i posted to the nodered docs
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.