How to use the RiveScript node from node-red-contrib-rive

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.

What did you expect to get?
as some text is the only answer you defined this is all the node will return.
Isnt this what you would expect?

Johannes

To me, the “first steps” at the official RiveScript tutorial was a great starting point back in the day: https://www.rivescript.com/docs/tutorial

2 Likes

Sorry, I had some other entries in the RiveScript file, but none of them worked.

Like this:

+ my name is *
- Hello, <star> 

+ hello bot
- hello back, guy!

So I wrote in Telegram hello bot, but got an error on the second output:

ERR: No Reply Matched

or after inserting + * I got the text some text, which means, he didn't find a matching line.

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:

Sorry, I do not understand, what content I should use in msg.context and what the RiveScript would do with that content!?

indeed :frowning:

Here is the change node I use before my rivescript node:

And an example script:

! 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 #

Hi Julian,

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.

Maybe you could share a test flow?

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 found my error, when building a test flow:

I always used a "!" at the end of the + line.

+ hello bot!

then the line will NOT be found.

The RiveScript tutorial states:

Important Note: a trigger is ALWAYS lower cased, and it doesn't contain punctuation symbols.

The examples above were correct, but I didn't use these. Sorry!!

1 Like

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.

1 Like

Ah, ok. It seems as if could use these variables some day. Thanks for the clarification!

Hi,
sorry to break into this thread. I am rather confused with the rivescript node too. I am trying a simple test:
! version = 2.0

  • hello bot
  • Hello, human!

with the input coming from a telegram receiver node. It contains:

{"chatId":***********,"messageId":23,"type":"message","content":"hello bot"}

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.

Martyn

Telegram Receiver uses msg.payload.content. You may have to move the "hello chat" to msg.payload with a change node.
grafik

gotcha, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.