Describe enums in Bot Framework & FormFlow with JSON Schema - enums

I'd like to create a Bot using the FormFlow with JSON Schema approach. However, I need a bit more flexibility for displaying the answer options, since those need to be whole sentences and not only single words.
Is it possible to extend the enums specified inside the JSON file with descriptions that will be offered as options instead of the enum itself?
As I understand this is possible in code by using the Describe-Attribute.

You could use the "Define" property with custom script. The Sandwich Bot example is doing it this way (from json-schema-example):
"Define": "field.SetType(null).AddDescription(\"cookie\", DynamicSandwich.FreeCookie).AddTerms(\"cookie\", Language.GenerateTerms(DynamicSandwich.FreeCookie, 2)).AddDescription(\"drink\", DynamicSandwich.FreeDrink).AddTerms(\"drink\", Language.GenerateTerms(DynamicSandwich.FreeDrink, 2)); return true;",

Related

How do I use capture groups in Regular Expressions in Bot Composer

I am attempting to build a Microsoft Teams bot using the Bot Framework Composer. What I would like to do is create an integration with ServiceNow. The goal would be that if anyone posts a record number (ex. REQ0123456, INC0123456, KB0123456) into the group or direct chat (with the bot), the bot would look up that record and provide a card or a short summary of the record to the chat.
To avoid creating a completely separate intent for each record type, I was hoping to use RegEx to gather the match into 2 capture groups; one for the tbl_code and one for the number.
Here is the entry for the user input:
> add some example phrases to trigger this intent:
- look up {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lookup {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
- lu {conversation.sn_record.tbl_code=REQ}{conversation.sn_record.number=0123456}
> entity definitions:
# regex sn_record tbl_code, number = /([a-z]{2,4})([0-9]{7})/mi
The Issue I'm Having
I don't know how to get the values back from the individual capture groups. I would like to have them separate so that I can determine which table needs to be queried. I could probably just use the entire match and the search API in ServiceNow for the whole record string, but I would still like to know how to use capture group values.
I'm currently using turn.recognized.text, but I don't think this is the best method for what I'm looking to do. This returns the entire regex match.
I'm very new to this framework, so please be gentle. :) Let me know if there is more information I can provide.
Thanks all.
Best Regards,
Josh
I was able to figure this one out using the examples in the ToDosSample bot.
The answer was to use named capture groups and then add them to a dialog property to use in the corresponding dialog.
For reference here are the changes I had to make:
New Regex
(?<sn_record>(?<tbl_code>[a-z]{2,4})(?<numbers>[0-9]{7}))
New Dialog Properties
dialog.sn_record = #sn_record
dialog.sn_tbl_code = #tbl_code
dialog.sn_numbers = #numbers
New response
- Okay, looking up ${dialog.sn_tbl_code}${dialog.sn_numbers}

spring properties - structure

I've got a scenario where I have the following type of data that I want to specify in my properties file.
To describe it I have a domain, each which can have a type and subtype.
wallet.items.domain=APPLE,DOMAIN_TWO
wallet.domain.types.apple=TYPE_ONE, PAYPAL
wallet.domain.subtypes.apple=SUB_TYPE_ONE
wallet.domain.types.paypal=TYPE_ONE, TYPE_TWO, TYPE_THREE
wallet.domain.subtypes.paypal=SUB_TYPE_ONE, SUB_TYPE_TWO, SUB_TYPE_THREE, SUB_TYPE_FOUR
I want to validate that the types and the subtypes for a domain are valid in a generic manner. For example these are valid combinations.
APPLE, TYPE_ONE, SUB_TYPE_ONE
APPLE, TYPE_TWO, SUB_TYPE_ONE
APPLE, TYPE_TWO, SUB_TYPE_ONE
PAYPAL,TYPE_ONE,SUB_TYPE_ONE
My first challenge is to structure this in a properties file such that I can use them in a validate routine in groovy generically.
I'm using spring for property file mnmgt.
Can anyone help me with a nice generic way to do this?

How to ask open questions in bot framework?

I am building a chat bot using Bot Framework, C# Bot Builder and FormFlow (with FieldRelfector).
At one step I need to ask an open question to the user like "Add any other relevant information", where I just want to collect some text and store it for later usage.
I tried to define the variable as String:
[Prompt("Add any other relevant information")]
public string OpenText;
In the form chain I have:
.Field(new FieldReflector<MyForm>(nameof(OpenText))
.SetType(null)
.SetActive(state => !state.Finished()))
but that doesn't help, whatever I type the bot answers:
"blah blah" is not a open text option.
How to handle this?
Is there any reason you are using a FieldReflector for that property? I would suggest just defining a normal field for that property (you can have a form with fields defined with FieldReflector and fields defined just with Field).
Just use:
.Field(nameof(MyForm.OpenText), state => !state.Finished())
If there is a reason to use FieldReflector, please update the post with the entire form definition.

Epi server - make content area specific for block

I would like to achieve the following thing-
Build a pagetype which has 3 different ContentArea's and that the user can put only a specific block type in each of these areas.
For example - ContentArea1 can only accept block type of "BlockType1", ContentArea2 can only accept "BlockType2" and so on. (It doesn't need to be generic, I can specify hard coded which type should fit in each Content Area.
Is it possible to achieve?
Maybe there is another way?
(I know you can create a property with the block type, but I want to use the same block in different places)
ps: using EPI-SERVER 8
From version 8.0 of EPiServer there is better support for AllowedTypes.
The feature was also available before version 8, but was more limited.
In short, you decorate your ContentArea property with the AllowedTypes attribute and EPiServer takes care of the rest.
Read more about it here:
http://world.episerver.com/blogs/Ben-McKernan/Dates/2015/2/the-new-and-improved-allowed-types/

Data abstraction in API Blueprint + Aglio?

Reading the API Blueprint specification, it seems set up to allow one to specify 'Data Structures' like:
Address
street: 100 Main Str. (string) - street address
zip: 77777-7777 (string) - zip / postal code
...
Customer:
handle: mrchirpy (string)
address: (address)
And then in the model, make a reference to the data structure:
Model
[Customer][]
It seems all set up that by referencing the data structure it should generate documentation and examples in-line with the end points.
However, I can't seem to get it to work, nor can I find examples using "fully normalized data abstraction". I want to define my data structures once, and then reference everywhere. It seems like it might be a problem with the tooling, specifically I'm using aglio as the rendering agent.
It seems like all this would be top of the fold type stuff so I'm confused and wondering if I'm missing something or making the wrong assumptions about what's possible here.
#zanerock, I'm the author of Aglio. The data structure support that you mention is a part of MSON, which was recently added as a feature to API Blueprint to describe data structures / schemas. Aglio has not yet been updated to support this, but I do plan on adding the feature.

Resources