I read about RiveScript for using with Telegram bots, which I can use instead of a large switch node.
But I have not found, how to send the text from Telegram or any other node to the input of the RiveScript node.
I also used an inject node, but I can only see messages on the error output of the node.
If I use an RiveScript with
+ *
- some text
I get the some text as reply, but nothing else. I tried to read the js of the node in .node-red/node_modules/node-red-contrib-rive, but got lost.
I read the tutorial, but my problem is how the input text is read by the RiveScript node. Where should I put it? in msg.payload, msg.payload.content (as Telegram uses this variable) or msg.xxxxx?
In the rule, directly in msg.payload for all nodes, unless the node requests otherwise. If needed to move it for telegram, put a change node before or after the RiveScript node
The node you use could do with way better documentation. If you add a msg.script property, it will use that instead of the template. If msg.context exists it will use it as the RiveScript context (as object).
It will then use msg.payload as input text:
! version = 2.0
! array cmds = on off
+ # (@cmds)
- |01,<star1>,<star2>
+ (@cmds) #
- |01,<star2>,<star1>
+ (@cmds)
- |02,Which switch/light would you like to turn <star1>? [1-10]
+ #
- |03,Would you like to turn switch/light <star1> on or off? [on|off]
+ *
- I'm sorry, I don't understand what you are asking for.\n
^ Please use the format: /light # on|off\n
^ You can even use: /on #
I already saw your examples, but in my case it is a lot more simple.
But I don't get a result, when injecting a string in msg.payload, which I have defined in a + line.
As I understood Lena (@afelix), I have to fill some content in msg.context, when using msg.payload!?
I think, I have to make small flow. Maybe there is some nasty little error, which drives me nuts.
No you don’t, it’s optional, and it’s for if you want to use RiveScript’s context processing on messages, as explained in the link for RiveScript before
In Tutorial - RiveScript.com I have not found any "context". And the js code was not clear to me. Nevermind, I don't think, I will need the context.
I will post my test flow in a few minutes.
I just took a look again, and I understand your confusion. This node is inspired by a set of chat nodes that invent their own whole context idea, if you’re familiar with that set it makes a bit more sense but simply said this node needs way better documentation.
The context is actually mentioned in the rivescript docs but has a different name there. It’s what they refer to as user variables near the very end. If you were to set msg.context.user, it’s usuable in your script as <id>, but if unset defaults to localhost like the rivescript docs describe. msg.context.vars is an object too, containing the set of user variables for this user, that you can use with <get> and <set> in your script.
but I get ERR: No Reply Matched? I suspect that I need a change node but I cannot figure out what it needs to be changed to? I agree the documentation is somewhat sparse.