Spintax is a compact notation to write down a variety of strings.
The appearance may remind some of you of regular expressions. But spintax is not about matching strings and having less options the interpretation is simple as you will see in a second.
Below are some examples and some possible outcomes:
-
Let's start simple:
"[Hello|Hi]" ==> "Hello" or "Hi"
-
You are not limited to two variants, there may be multiple spintax expressions in one string:
"[Hello|Hi|Cheerio|How do you do?|Welcome|Nice to have you here]" ==> "Hi" or "Welcome" or ...
-
You can have multiple spintax expressions within a string description:
"[Hello|Hi] [my friend|again]" ==> "Hello again" or "Hi my friend" or ...
-
One option can be left empty to make parts of the text optional:
"[ | Good Bye]" ==> "" or "Good Bye"
-
Nested spintax expressions are supported. This makes spintax a powerful tool:
"[Hello|Hi] [|my [|best] friend ]" ==> "Hello", "Hi my friend", "Hello my best friend", ...
Before processing the output the hook searches for "message" and "reprompt" entries to create one random utterance from all the possible permutations (there may be a lot!) which are described by the spintax expression.
The resulting string is the utterance the user will receive from the system.
If there is no spintax the string remains as is.
The hook will also clean up multiple whitespace.
This project shows you the files which needs to be modified to make things work.
If you need more explanation you may want to follow the description in the Jovo documentation.
There are two things to keep in mind:
-
For sure you want users to launch your voice app very often.
-
For sure users will complain your voice app is boring if they have to listen to the same utterances over and over again
Spintax can help you to bring variety into your utterances.
No. You could also have a look at the Jovo plugin concept. You can find an example implementation for Spintax using the plugin approach here.
Definitely! Using spintax in your project can help you to save time and make maintenance easier.
To show what is possible I also wrote an online spintax tool which you can use for whatever you may find useful.
Going one step further there is also a tool to describe and maintain complete Alexa voice models using spintax. Furthermore you may want to read my LinkedIn article about Spintax to find out more.