Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
cname: play.botscript.ai
cname: botscript.yeu.ai
115 changes: 56 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Here is a list of resources to get you started

- 👯 [Read the wiki](https://github.com/yeuai/botscript/wiki) for all the details on how to get started playing with BotScript
- 🤔 [Read API References](https://github.com/yeuai/botscript/wiki/API-References) to start coding
- 💬 [Playground](https://play.botscript.ai/) to say hello?
- 💬 [Playground](https://botscript.yeu.ai/) to say hello?

# Specification

Expand Down Expand Up @@ -92,7 +92,7 @@ Example:

## dialogue

A dialogue is a piece of conversation that human and bot interact with each other.
A dialogue is a piece of conversation that human and bot interact with each other.

A dialogue must contains a `+` line, that defines a pattern can activate the bot to respond. This line also called with other name **trigger**.

Expand All @@ -114,13 +114,13 @@ Example:

A dialogue may contains:

* triggers
* replies
* flows
* conditions
* variables
* commands
* prompts
- triggers
- replies
- flows
- conditions
- variables
- commands
- prompts

## triggers

Expand Down Expand Up @@ -156,9 +156,9 @@ A dialogue may contains more than one trigger. Which helps bot to detect exactly

A trigger may contains:

* definitions
* patterns
* variable
- definitions
- patterns
- variable

## replies

Expand All @@ -173,12 +173,12 @@ A reply begins with `-` symbol in the dialogue and goes with the trigger. If the

A reply may contains:

* definitions
* variables
- definitions
- variables

## flows

Flows are tasks which need to be resolved. A flow can used to determine a precise flow of conversation
Flows are tasks which need to be resolved. A flow can used to determine a precise flow of conversation

A flow must start with a `~` line, that defines the the task name.

Expand Down Expand Up @@ -210,13 +210,13 @@ The dialogue jumps to the splash flow then back to continue.

A flow may contains:

* triggers
* replies
* flows
* conditions
* commands
* variables
* prompts
- triggers
- replies
- flows
- conditions
- commands
- variables
- prompts

## prompts

Expand All @@ -243,14 +243,14 @@ Example:

## conditions

A conditions begins with star symbol: `*`
A conditions begins with star symbol: `*`

Syntax: `* expression`

There are two categories of conditions in the dialogue:

* [x] **Conditional activation**: monitoring the ability to activate the dialogue in the conversation
* [x] **Conditional reply**: checking the operation process in the dialogue and ability to respond to human
- [x] **Conditional activation**: monitoring the ability to activate the dialogue in the conversation
- [x] **Conditional reply**: checking the operation process in the dialogue and ability to respond to human

For example:

Expand All @@ -270,12 +270,12 @@ Syntax: `* expression [type] [action]`

There are six subcategories of conditional processing:

* Conditional reply
* Conditional flow
* Conditional redirect
* Conditional command
* Conditional prompt
* Conditional event
- Conditional reply
- Conditional flow
- Conditional redirect
- Conditional command
- Conditional prompt
- Conditional event

Example:

Expand Down Expand Up @@ -384,7 +384,7 @@ A variable appears in a dialogue in both triggers and replies.

A variable is declared within parentheses: `*{var1}` to capture a string and `#{var2}` to captures a number.

A variable is populated in replies by defining after `$var1` sign or within form `${var2}`.
A variable is populated in replies by defining after `$var1` sign or within form `${var2}`.

Example:

Expand All @@ -398,20 +398,20 @@ Example:

System variables:

* `$previous`: history of dialogue chat
* `$flows`: available in context of dialogue is flowing
* `$input`: human message input
- `$previous`: history of dialogue chat
- `$flows`: available in context of dialogue is flowing
- `$input`: human message input

## patterns

A pattern within trigger which helps the dialogue `human <-> bot` can be activated and bot has a better capability to reply human.
A pattern within trigger which helps the dialogue `human <-> bot` can be activated and bot has a better capability to reply human.

Advanced pattern helps bot exactly knows what human is saying.

There are two ways add pattern capability in BotScript:

* Built-in pattern capability using Regular Expression
* Custom pattern capability by add new handler
- Built-in pattern capability using Regular Expression
- Custom pattern capability by add new handler

### 1. Built-in pattern capability using Regular Expression

Expand Down Expand Up @@ -455,7 +455,7 @@ BotScript allows to define plugins which will be activated usage if the one adde
A plugin started with `>` line for pre, post-processing
A plugin runs in pipeline of message request processing
A plugin may contain conditional activation
A plugin may be grouped in a group
A plugin may be grouped in a group

Syntax:

Expand All @@ -477,21 +477,21 @@ Example:
- it is $time
*/
function addTimeNow(req: Request, ctx: Context) {
const now = new Date()
req.variables.time = `${now.getHours()} : ${now.getMinutes()}`
const now = new Date();
req.variables.time = `${now.getHours()} : ${now.getMinutes()}`;
}

/**
* plugin for post-processing
* */
function noReplyHandle() {
const postProcessing = (res: Request) => {
if (res.message === 'NO REPLY!') {
res.message = `Sorry! I don't understand!`
if (res.message === "NO REPLY!") {
res.message = `Sorry! I don't understand!`;
}
}
};

return postProcessing
return postProcessing;
}
```

Expand All @@ -509,18 +509,18 @@ Syntax:

Available built-in supported directives:

* include
* nlu
* format
* plugin
- include
- nlu
- format
- plugin

### Directive /include

Example:

```bash
# import botscript document from urls
/include:
/include:
- url 1
- url 2
```
Expand Down Expand Up @@ -564,7 +564,7 @@ A plugin is compiled in the script document and one defined in a directive:

Syntax:

~~~bash
````bash
/plugin: name
```js
# javascript code here;
Expand All @@ -580,32 +580,29 @@ return (req, ctx) => {
}
}
```
~~~
````

Example:

~~~bash
````bash
# add time now to current variable for each request
/plugin: addTimeNow
```js
const now = new Date();
req.variables.time = `${now.getHours()}:${now.getMinutes()}`;
```
~~~
````

# Examples

See the [`examples/`](./examples) directory.


Contributing
============
# Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please [create an issue](https://github.com/yeuai/botscript/issues/new).

License
=======
# License

BotScript is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
8 changes: 4 additions & 4 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<!--link app scripts-->
<script src="https://play.botscript.ai/botscript.ai.js"></script>
<script src="https://play.botscript.ai/botscript.plugins.js"></script>
<script src="https://botscript.yeu.ai/botscript.ai.js"></script>
<script src="https://botscript.yeu.ai/botscript.plugins.js"></script>
</head>

<body>
Expand All @@ -19,7 +19,7 @@
<h1 class="display-3">Hello, BotScript!</h1>
<p>A text-based scripting language, dialog system and bot engine for Conversational User Interfaces</p>
<p>
<a class="btn-primary btn-lg" href="https://v2.botscript.ai/#/register" target="_blank">Register Now &raquo;</a>
<a class="btn-primary btn-lg" href="https://yeu.ai/#/register" target="_blank">Register Now &raquo;</a>
<iframe src="https://ghbtns.com/github-btn.html?user=yeuai&repo=botscript&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
</p>
Expand All @@ -42,7 +42,7 @@ <h2 id="greeting">Do you have any questions to ask BotScript?</h2>
/include:
- https://raw.githubusercontent.com/yeuai/botscript/master/examples/definition.bot
- https://raw.githubusercontent.com/yeuai/botscript/master/examples/basic.bot
${botId ? '- https://botscript.ai/api/kb/' + botId : ''}
${botId ? '- https://botscript-core.yeu.ai/api/kb/' + botId : ''}

@ geoip https://api.ipify.org/?format=json
#- header: value
Expand Down
Loading