Download Bot Libre Desktop, your own personal bot for your PC or Mac
Bot Libre Forum

run a script in a greeting

by bobred posted 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: 2240, today: 0, week: 0, month: 47

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: 2276, today: 0, week: 0, month: 37

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: 2376, today: 0, week: 0, month: 45

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: 2239, today: 0, week: 0, month: 45

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: 2316, today: 0, week: 0, month: 39

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: 2168, today: 0, week: 0, month: 32

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: 2209, today: 0, week: 0, month: 37

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: 2270, today: 0, week: 0, month: 37

by bobred posted Oct 10 2018, 18:34

okay I did not know that.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2227, today: 0, week: 0, month: 33

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: 2185, today: 0, week: 0, month: 39

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: 2187, today: 0, week: 0, month: 31

by bobred posted Oct 19 2018, 9:30

thankyou that worked.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2209, today: 1, week: 1, month: 44

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: 2167, today: 1, week: 1, month: 38

Id: 23866396
Tags: programming
Posted: Oct 3 2018, 19:06
Replies: 13
Views: 3930, today: 1, week: 1, month: 134
0 0 0.0/5