Reputation: 21
Does the Dialog service support emoji inputs?
I was able to output emojis using both: HTML Entity (decimal) HTML Entity (hex) http://www.fileformat.info/info/unicode/char/1f37b/index.htm
However, I can't get the dialog service to understand emoji inputs. Emojis in dialog conversation
Upvotes: 2
Views: 1768
Reputation: 877
You most certainly can. Here’s an example:
<?xml version="1.0" encoding="UTF-8" ?>
<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<flow>
<folder label="Main">
Output an initial prompt:
<output>
<prompt>
<item>Write something and I’ll echo it back to you.</item>
</prompt>
</output>
Get input:
<getUserInput>
<input>
<grammar>
<item>(ANYTHING)={anything}</item>
</grammar>
<action varName="anything" operator="SET_TO">{anything.source}</action>
<output>
<prompt>
<item>{anything}</item>
</prompt>
</output>
</input>
</getUserInput>
</folder>
</flow>
Now, I guess you have tried to capture inputs the way IBM does it in all its examples. But that method silently drops many non-ASCII characters. It’s just not how you want to capture inputs. (See this SO answer for a list of some of the characters it drops.)
Here’s how I do it:
<entities>
<entity name="ANYTHING">
<value>
<grammar>
<item>!.*</item>
</grammar>
</value>
</entity>
</entities>
The exclamation point means that we’re using a regular expression. (Everything after !
is the regex.) This method does not drop as many characters, but it will drop <
and >
. Possibly others. You can use this same script to find out which characters are safe.
And finally we’ll need the variable to capture into.
<variables>
<var_folder name="Home">
<var name="anything" type="TEXT" />
</var_folder>
</variables>
</dialog>
See this gist for the complete example.
Upvotes: 1