Aktualizacja Platinum serwis i zrobić swój własny projekt 3D avatar
Bot Libre Forum

run a script in a greeting

w bobred wysłany Oct 3 2018, 19:06

can I run a self script in a greeting?


by bobred posted Oct 3 2018, 20:22

I figured out how to make  the chatbot know the hour with the greeting.so it can ask if you want breakfast, dinner or lunch.i am going to use that for that.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2242, today: 1, week: 2, month: 49

by admin posted Oct 4 2018, 9:17

To run code in a greeting there are 2 options, use a Template, or use a redirect.

For example, for a Template you can use something like:

Template("{var hour = Date.get(Date.date(), #hour); if (hour < 10) { "Good morning." } else if (hour > 18) { "Good evening." } else { "Good day." } }")

For a redirect, you use a Template in your greeting that does a redirect to a response that is handled by a script.

Template("{ redirect("script_greeting") }")

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2278, today: 2, week: 2, month: 39

by bobred posted Oct 4 2018, 10:45

that is good to know.But how do I rename a aiml script after I have made it.Because most of my new scripts I made are just called aiml.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2378, today: 1, week: 2, month: 47

by admin posted Oct 4 2018, 14:12
If you upload AIML from a file or our script library it gets the file/script name.
If you create a new AIML script from the bot's scripts it will be named 'aiml', to have a different name, first save it as a Self script with the name, then change the code to AIML.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2242, today: 1, week: 3, month: 48

by bobred posted Oct 6 2018, 8:03

redirect to a script does not work because the default response overrides it.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2320, today: 3, week: 4, month: 43

by admin posted Oct 9 2018, 12:36
I have tested this, and it does work.

I'm not sure what you tried.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2172, today: 2, week: 4, month: 36

by bobred posted Oct 9 2018, 19:55

This script is what I was talking about.

 

Template("{ redirect("script_greeting") }")


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2210, today: 1, week: 1, month: 38

by admin posted Oct 10 2018, 13:28
So a "redirect" send the redirect text as a message to the bot and returns the response.

For example if a bot had a script that had the pattern "hello" and returned "hello world", then in a Template redirect("hello") would return "hello world".

In my example "script_greeting" was an example message, you need a script that accepts this pattern and return your desired response. If you have no response for "script_greeting", then your bot would use its default response.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2273, today: 2, week: 3, month: 40

by bobred posted Oct 10 2018, 18:34

okay I did not know that.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2229, today: 2, week: 2, month: 35

by bobred posted Oct 10 2018, 19:11

this is what Sheila bing greeting is now.wait here.walks away down the hallway.comes back 30 minutes.here is your script_hour on a tray. 

i have a a aiml script called hour and it has hour as a pattern.

put in the search Sheila bing rating= mature


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2187, today: 2, week: 2, month: 41

by admin posted Oct 19 2018, 8:02
Looking at your bot, your greeting redirects to the question "script_hour" but you have no response for this.

In your script the pattern should be "script_hour" not "hour".

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2190, today: 3, week: 3, month: 34

by bobred posted Oct 19 2018, 9:30

thankyou that worked.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2212, today: 2, week: 4, month: 47

by bobred posted Oct 19 2018, 12:21

the redirect script does not work with the random tag.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2171, today: 2, week: 5, month: 42

Identyfikator: 23866396
Tagi: programming
Wysłany: Oct 3 2018, 19:06
Odpowiedzi: 13
Widok: 3935, dziś: 2, tydzień: 6, miesiąc: 139
0 0 0.0/5