Wussten Sie Bot Libre bietet auch Kostenlose gehostete live-chat für Ihre eigene website oder mobile app?
Bot Libre Forum

run a script in a greeting

durch bobred gepostet 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: 2006, today: 0, week: 5, month: 10

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: 2051, today: 0, week: 3, month: 6

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: 2119, today: 0, week: 4, month: 15

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: 2013, today: 0, week: 7, month: 13

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: 2088, today: 0, week: 7, month: 13

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: 1946, today: 0, week: 11, month: 14

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: 1985, today: 0, week: 5, month: 7

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: 2036, today: 1, week: 11, month: 19

by bobred posted Oct 10 2018, 18:34

okay I did not know that.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2005, today: 1, week: 8, month: 15

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: 1967, today: 0, week: 3, month: 10

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

by bobred posted Oct 19 2018, 9:30

thankyou that worked.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1972, today: 0, week: 5, month: 13

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: 1938, today: 1, week: 4, month: 9

Id: 23866396
Tags: programming
Gepostet: Oct 3 2018, 19:06
Antworten: 13
Ansichten: 3365, heute: 1, Woche: 15, Monat: 39
0 0 0.0/5