Comments (32)
from node-red-contrib-chatbot.
some infos about stack error:
TypeError: msg.chat is not a function at TelegramOutNode.<anonymous> (/root/.node-red/node_modules/node-red-contrib-chatbot/chatbot-telegram-receive.js:391:29) at emitOne (events.js:77:13) at TelegramOutNode.emit (events.js:169:7) at TelegramOutNode.Node.receive (/usr/lib/node_modules/node-red/red/runtime/nodes/Node.js:211:14) at FunctionNode.Node.send (/usr/lib/node_modules/node-red/red/runtime/nodes/Node.js:198:14) at sendResults (/usr/lib/node_modules/node-red/nodes/core/core/80-function.js:47:18) at FunctionNode.<anonymous> (/usr/lib/node_modules/node-red/nodes/core/core/80-function.js:184:21) at emitOne (events.js:77:13) at FunctionNode.emit (events.js:169:7) at FunctionNode.Node.receive (/usr/lib/node_modules/node-red/red/runtime/nodes/Node.js:211:14) at ChangeNode.Node.send (/usr/lib/node_modules/node-red/red/runtime/nodes/Node.js:133:22) at ChangeNode.<anonymous> (/usr/lib/node_modules/node-red/nodes/core/logic/15-change.js:245:22...
from node-red-contrib-chatbot.
Issue still persist, tried some different things, but it appears chat object is not preserved during session transition between different flows like mine
from node-red-contrib-chatbot.
@gabbiano83 sorry for taking so long to answer.
Basically in msg.originalMessage and msg.chat() are stored all information needed to track the current conversation with the end user.
As general pattern in node-red a node should manipulate the inbound message just adding/changing the value in msg.payload and keeping the original msg object.
So no matter how many node you could chain, at the end of the flow in the outbound message you should be able to find the right msg.originalMessage and the method msg.chat().
If this is not happening means that some node in the flow is cleaning up the msg object.
I don't know how it's designed your flow but you could place a debug node out of every inner node and check where the .chat() method disappears, then we can give a look at that node and find a work around.
Meanwhile I can improve the error handling in case the chat() method is not found
from node-red-contrib-chatbot.
Thanks, I guess that, but my main issue is that currently I'm using a flows with MQTT to send remotely "msg.payload" only.
Do you have any idea about how I can preserve msg.originalMessage?
I've already tried to move msg.originalMessage on msg.payload.originalMessage field and after the message receive on the remote site move back msg.payload.originalMessage to msg.originalMessage, but this issue still persist.
from node-red-contrib-chatbot.
ok, the chat() method is not essential in the outbound node, the originalMessage should be enough, I can fix it and then try if your solution to put back the originalMessage works
from node-red-contrib-chatbot.
Grazie :)
from node-red-contrib-chatbot.
@gabbiano83 ok can you try this beta version (I've to fix more bugs before a release)
npm install [email protected]
from node-red-contrib-chatbot.
Funziona!!!!!!!!
It works
Grazie mille :)
from node-red-contrib-chatbot.
Same issue for me, @guidone
I have 0.9.25 version.
If i try to install beta version as suggested, doesn't wotk (probably because my actually version is newest).
Did you think i must to uninstall my actyally version and install the old beta you suggest before?
from node-red-contrib-chatbot.
Yes the beta is old, perhaps itβs a different problem.
Can you send exactly what you see in system console?
from node-red-contrib-chatbot.
"TypeError: message.chat is not a function"
the same error of @gabbiano83
from node-red-contrib-chatbot.
Can you share the flow (export), in this way I can debug on my box?
from node-red-contrib-chatbot.
[{"id":"2e65bf09.2da18","type":"chatbot-telegram-send","z":"f65fe3d9.4eac4","bot":"ecd8cf46.a180a","botProduction":"","track":false,"outputs":0,"x":1027,"y":190,"wires":[]},{"id":"e1dea7ab.5cf378","type":"link in","z":"f65fe3d9.4eac4","name":"From MQTT","links":["369d9092.04346","935c5e87.642e2","e312e8e8.277d08"],"x":276,"y":246,"wires":[["278f8bf6.343b14"]]},{"id":"bbb93433.48ad28","type":"link in","z":"f65fe3d9.4eac4","name":"From Telegram","links":["b6fc05e7.ef79b8"],"x":279,"y":431,"wires":[["179d0689.90bcc9"]]},{"id":"fcded81d.969fd8","type":"debug","z":"f65fe3d9.4eac4","name":"Telegram Response","active":true,"console":"true","complete":"payload","x":1047,"y":264,"wires":[]},{"id":"278f8bf6.343b14","type":"change","z":"f65fe3d9.4eac4","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":479,"y":244,"wires":[["f04066b.6275f98"]]},{"id":"f04066b.6275f98","type":"join","z":"f65fe3d9.4eac4","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","x":756,"y":389,"wires":[["fcded81d.969fd8","2e65bf09.2da18"]]},{"id":"179d0689.90bcc9","type":"change","z":"f65fe3d9.4eac4","name":"","rules":[{"t":"delete","p":"payload.content","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":497,"y":432,"wires":[["f04066b.6275f98"]]},{"id":"ecd8cf46.a180a","type":"chatbot-telegram-node","z":"","botname":"vodaxxx_bot","usernames":"","polling":"1000","store":"","log":"/var/log/Node-RED_Telegram_vodaxxx_bot.log","parseMode":""}]
from node-red-contrib-chatbot.
However, when i send a flow to "Telegram Sender" activity, what is the format of structure it expect? Can you post an example? So i think to remap input data for this activity
from node-red-contrib-chatbot.
Update:
i created a custom function between previus palette and telegram sender palette with this code:
var chatId = msg.payload.chatId;
var userId = msg.payload.userId;
var messageId = msg.payload.messageId;
var transport = msg.payload.transport;
var authorized = msg.payload.authorized;
var message = msg.payload.message;
var firstName = msg.payload.firstName;
var type = msg.payload.type;
var ts = msg.payload.ts;
var inbound = msg.payload.inbound;
var content = msg.payload.content;
msg.payload = {
type: type,
chatId: chatId,
userId: userId,
ts: ts,
transport: transport,
inbound: inbound,
content: content/*,
messageId: messageId,
authorized: authorized,
message: message,
firstName: firstName*/
};
return msg;
It seems that the issue come from msg.payload.content.
If i set content variable to a static string like "hello world", the flow works fine, otherwise if i set this one to msg.payload.content, sometimes works, other times got error.
Note that msg.payload.content is set once a time from other activities, depending from various conditions
from node-red-contrib-chatbot.
Seems to me that you're trying to work directly with the internals of Telegram sender
and this is fundamentally wrong, there are a lot of higher level nodes to send text messages, images, etc.
More: the internal behaviour is likely to change in the next versions and any code dealing directly to it will break.
This kind of error happens when something that is not e RedBot message is sent to Telegram sender
(yes, it could more robust and perform some kind of check).
What exactly are you trying to accomplish - at hight level - with this flow?
from node-red-contrib-chatbot.
I want to accomplish a request/replay activity with command send by telegram.
The received telegram command is forwarded to a subflow that execute an activity.
One of this activity send a message to MQTT sender, so the receiver MQTT perform the action and send back the answer that i want to send back to chat user by telegram.
Another activity triggered by telegram command, is to execute a pre set system command and send back the output to telegram.
The main requirement is to replay on the same chat started by a user (anyone user can send commands to my chat bot, but i will provide soon a restriction to allowed users only).
I can't use the "conversation" activity for my purpose because the chatId input is needed to be passed statically, and in my purpose chatId is a variable value assigned to a user that start conversation.
If there is a way to pass chatId dynamically to this activity, i will solve my issue.
Any suggestion to this?
Thanks
from node-red-contrib-chatbot.
Yes it's possible
https://github.com/guidone/node-red-contrib-chatbot/wiki/Conversation-node
The parameters chatId and transport can be passed through the payload by the upstream Function node
:
msg.payload = {
chatId: '42' // your variable here
};
return msg;
it should work
from node-red-contrib-chatbot.
so i have to put a function actvity before conversation activity with this code (properly modified for my purpose), and leave blank chatId field into conversation activity?
from node-red-contrib-chatbot.
exactly, all redbot nodes work in this way, it's always possible to specify parameters programmatically in the payload
from node-red-contrib-chatbot.
Ok i will try and replay you soon for confirmation...
from node-red-contrib-chatbot.
OK it works!
Solved using Conversation activity between Join and Telegram Sender Activity.
In conversation activity Transport and Telegram Bot must be configured while ChatId and MessageId must be leaved blank.
Attributes must be passed by payload (these come from Join Activity), so the flow works great.
Thank you very much !
from node-red-contrib-chatbot.
Perfect!
from node-red-contrib-chatbot.
Hi,
I like to send to telegram the value of variable stored on msg.payload from mqtt value.
How I can send this value?
Best
from node-red-contrib-chatbot.
Many thanks guidone
from node-red-contrib-chatbot.
I have the same problem, I send a msg.payload with a simple string and I've the error ((
Why there is no description informations and not example?
[{"id":"15439243.067de6","type":"inject","z":"502fd5ce.9341e4","name":"","topic":"","payload":"1000","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":280,"wires":[["d685eb58.6f967"]]},{"id":"d685eb58.6f967","type":"function","z":"502fd5ce.9341e4","name":"","func":"msg = {payload:\"prova ciao\"}\nreturn msg;","outputs":1,"noerr":0,"x":110,"y":380,"wires":[["2a584f05.57239","c410c6fb.5d903"]]},{"id":"2a584f05.57239","type":"chatbot-telegram-send","z":"502fd5ce.9341e4","bot":"487af552.539ccc","botProduction":"487af552.539ccc","track":false,"passThrough":false,"outputs":0,"x":280,"y":440,"wires":[]},{"id":"487af552.539ccc","type":"chatbot-telegram-node","z":"","botname":"Domotica","usernames":"","providerToken":*********************","polling":"1000","store":"3a955f86.7602d","log":"","parseMode":"","debug":false},{"id":"3a955f86.7602d","type":"chatbot-context-store","z":"","name":"","contextStorage":"memory","contextParams":""}]
What is the difference betwen token and provider token? What users field is for?
Also I can't receive nothing with Telegram receiver..
from node-red-contrib-chatbot.
I've tried also to add message node, but no output from it.
WHen I deploy now NR take 10 seconds.. (before less then 1)
from node-red-contrib-chatbot.
You need to put a conversation node (https://github.com/guidone/node-red-contrib-chatbot/wiki/Conversation-node) before everything
from node-red-contrib-chatbot.
Thank you for your kind answer. I follower your scheme, now I don't have more the error, but I don't understand to whom I'm sending messages, where should I specify the destination contact? Maybe the bot just write into its chat, and who is connected to it.. all can see. I'v eno idea.
I'm sending messaged to it from phone and I got an error: [polling_error] {"code":"EFATAL","message":"EFATAL: Error: connect ETIMEDOUT 149.154.167.220:443" in the consolle. On the phone the message is sent and delivered, not read. I'm in Russia and it looks like a limitation, but with my phone I?m under the same wifi and the phone works..
both sender and receiver have the status connected
from node-red-contrib-chatbot.
These topics are already covered in the wiki and this thread
https://github.com/guidone/node-red-contrib-chatbot/wiki/Start-conversation
Telegram has issues in Russia, it's blocked, that could be the reason of the timeout
from node-red-contrib-chatbot.
Thank you, it is not blocked because under the same Wifi I connected my mobile phone and Telegram works. Most of probability new version of the app is using a server which is not blocked. How can I help you to find it?
Also, what is the logic to have a status "connected" (it means it verified the token, server is not blocked) and then have a timeout?
from node-red-contrib-chatbot.
Related Issues (20)
- Not getting data from private Slack channels HOT 1
- Documentation: Changelog is being populated with 'Untitled'
- Feature request: add phone number information HOT 1
- feature request: linkedin messenger
- npm ERR! errno ETIMEDOUT HOT 1
- Snyk vulnerabilities HOT 1
- Image URL param support?
- Telegram Webhook not responding
- An example of how to create mediaGroup?
- Telegram pinned_message
- MC not working in Docker HOT 1
- Viber Images
- install error on node red on pi HOT 6
- Uncaught Exception in Text node HOT 1
- Unable to install from Palette / Docker HOT 3
- Can I use this package to integrate with home-made web-app bot?
- FR: Support MarkdownV2 in Telegram messages.
- Elements not recognized
- Could not login to Mission Control
- FR: Support for Telegram reactions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-contrib-chatbot.