This website and apps are for sale. Only serious offers will be considered. Contact [email protected]

Bot Libre Forum

run a script in a greeting

por bobred postado 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: 1908, today: 0, week: 0, month: 27

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: 1834, today: 0, week: 0, month: 26

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: 2036, today: 0, week: 0, month: 30

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

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: 1969, today: 0, week: 0, month: 27

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: 1866, today: 0, week: 0, month: 28

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: 1813, today: 0, week: 0, month: 20

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: 1958, today: 0, week: 0, month: 27

by bobred posted Oct 10 2018, 18:34

okay I did not know that.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1961, today: 0, week: 0, month: 30

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: 1895, today: 0, week: 0, month: 30

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: 1860, today: 0, week: 0, month: 27

by bobred posted Oct 19 2018, 9:30

thankyou that worked.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1877, today: 0, week: 0, month: 32

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: 1846, today: 0, week: 2, month: 36

Id: 23866396
Tags: programming
Postado: Oct 3 2018, 19:06
Respostas: 13
Pontos de vista: 2739, hoje: 1, semana: 1, mês: 30
0 0 0.0/5