MicrosoftDocs / composer-docs

Public sync of existing composer-docs-pr repo
Creative Commons Attribution 4.0 International
2 stars 5 forks source link

No Example For Using Values From settings Scope #208

Closed itprofessional68 closed 1 year ago

itprofessional68 commented 1 year ago

Hi! Could you please provide an example of using a value from the settings scope in Bot Framework Composer 2.1.2? For example, this article mentions the settings scope and that it is read only, but there are no examples of how to set a property in BFC 2.1.2 to a value in the bot settings JSON. An example JSON is below with customer-specific settings removed for security reasons. If I want to reference the qna hostname in the JSON below, how do I accomplish that in Bot Framework Composer 2.1.2? Screenshots of setting a property in Composer would be very helpful. Note that customer is using BFC with Power Virtual Agents, so there are limitations - not sure if those limitations impact the user's ability to use values from the settings scope in dialogs.

Sample JSON of bot settings obtained using Bot Framework Composer 2.1.2:

{ "publishTargets": [ { "type": "pva-publish-composer", "name": "Publish '' to PVA", "configuration": "{\"botId\":\"\",\"envId\":\"\",\"tenantId\":\"\",\"baseUrl\":\"https://gcc.api.powerva.microsoft.us/\",\"deleteMissingDependencies\":true}", "lastPublished": "2022-10-28T11:55:19.480Z" } ], "applicationInsights": { "InstrumentationKey": "" }, "luFeatures": { "enablePattern": false, "enableMLEntities": false, "enableListEntities": false, "enableCompositeEntities": false, "enablePrebuiltEntities": false, "enableRegexEntities": false, "enablePhraseLists": false }, "languages": [ "en-us" ], "defaultLanguage": "en-us", "luis": { "endpoint": "", "authoringEndpoint": "", "name": "MY BOT", "authoringRegion": "", "authoringKey": "", "endpointKey": "" }, "skillConfiguration": {}, "customFunctions": [], "qna": { "hostname": "", "endpointKey": "", "subscriptionKey": "" }, "MicrosoftAppPassword": "" }


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

JonathanFingold commented 1 year ago

Are you looking for something like this?

image
itprofessional68 commented 1 year ago

@JonathanFingold Yes, but can you also pleaee cross-reference to a couple of example values that reside in the bot settings JSON (advanced settings)? Not sure how many colons to use in the property name as it probably depends on the JSON document hierarchy. It would be good to use an example of how to put your Custom question and answering subscription key and URL in the settings file and then reference it in a composer dialog. Hope that makes sense...

JonathanFingold commented 1 year ago

I'll start work on an update. I should have time this week to get it published.

JonathanFingold commented 1 year ago

I'm adding more information about the setting scope to the Memory scopes and properties article:

To see your bot's current settings in Composer, go to the Configure page and turn on the Advanced Settings View (json). To access settings properties and subproperties from within adaptive expressions, use JSON notation. Alternatively, use the jPath adaptive expression prebuilt function to retrieve information from a settings property.

For example, default QnA Maker properties are:

  "qna": {
    "hostname": "",
    "knowledgebaseid": "",
    "qnaRegion": "westus",
    "endpointKey": "",
    "subscriptionKey": ""
  },

To reference your knowledge base ID, use the adaptive expression, settings.qna.knowledgebaseid.

itprofessional68 commented 1 year ago

Thank you, @JonathanFingold! This is exactly what I was asking for. Now if you can add something to the documents to pull subscription keys from Azure Key Vault into the bot config, that would be awesome. Maybe a fish to fry another day. My point being it is probably best practice to store keys in AKV instead of the application JSON, for security reasons. I'm assuming those kind of calls to AKV can be made using REST. Might not be your team responsible for providing examples, but perhaps you can route to a team who can provide that. This kind of stuff will become more important as folks move away from using C# or TS with Bot Framework SDK and more of the low code approach using BFC or the upcoming Bot Builder Studio. Some organizations will want to secure access to the endpoint kingdoms (our current endpoint kingdom is the custom question and answering API that replaces QnA Maker. Thank you!

JonathanFingold commented 1 year ago

Unfortunately, I don't have a clear idea of how to do that using just Composer. There are more breadcrumbs on how you might do so in the Bot Framework SDK docs. Where are you in your process? Have you already begun development in earnest? (We're encouraging new users to look at Power Virtual Agents.)

itprofessional68 commented 1 year ago

Understand. We are pretty far along in the dev process. We are using PVA but you can't easily wire PVA up to REST endpoints like Language Studio custom question and answering without also using Bot Framework Composer. We are hoping the new Bot Builder Studio that is in closed preview will alleviate some of our pain points (like getting PVA/BFC to tie into Azure Key Vault to retrieve secrets). I tried wiring up our PVA/BFC bot to custom question answering service using endpoint settings specified in the bot settings file, but all combinations I tried would not work (including the examples you provided earlier). We might have to just work around by hard coding the endpoint settings into the HTTP POST requests until Bot Builder Studio hits GA. Im going to try one more time tomorrow before I throw up the white flag and try to get our TAM involved.

JonathanFingold commented 1 year ago

You can create Power Automate flows to make the HTTP requests and return the results, but there is a bit of a learning curve. Not sure if it's helpful to go down that road before GA. Here's a link to the relevant PVA docs: https://learn.microsoft.com/en-us/power-virtual-agents/advanced-flow.

itprofessional68 commented 1 year ago

Thanks. Yeah, we are making the calls as HTTP external requests using Bot Framework Composer, and then publish the bot logic into PVA. For really sophisticated dialog management, doing it in BFC seemed like the way to go for us. Whether you make the HTTP call from Flow or from BFC, you still have to store keys somewhere if not in the parameters of your HTTP call. What is bad about using BFC in combo with PVA is you can't add additional recognizers like QnA Maker recognizer. You can't even test your bot from BFC, you have to publish to PVA first, test, and then switch back to BFC for any bot logic changes. Too many interfaces to build a low code bot. Which is why we can't wait for Bot Builder Studio :-)

JonathanFingold commented 1 year ago

Gotcha. Here's a thread you can follow that talks about support for the new custom question answering Cognitive Service in Composer (https://github.com/microsoft/BotFramework-Composer/issues/9400).

itprofessional68 commented 1 year ago

Thanks. The article on support for the new custom question answering Cognitive Service in Composer is appreciated, but does not detail how to integrate Bot Framework Composer and Power Virtual Agents into the custom question answering Cognitive Service. For example, there are no screenshots on how to configure the bot settings in Composer and then use properties in dialogs that then reference the bot settings values. If I want to make a HTTP call to the custom question answering Cognitive Service, I currently have to hard code the prediction URL into my HTTP POST request, and then also specify my endpoint subscription key in the header of the HTTP POST request. I will try to edit this later today and provide a screenshot to illustrate what I am trying to do and how it is not working for me, no matter what combination of parameterized values I try to place in my HTTP POST request in BFC. It's very time consuming to try different values only to have it fail, because to test each combinaion of values, I have to first publish the changes to PVA from BFC, then switch to PVA to test the bot to see if I receive an error or not. Obviously, BFC will catch glaring syntax errors during the publish, but it is still very annoying to constantly switch back and forth between BFC and the PVA portal to test. One reason we are using BFC is so we can leverage adaptive cards in dialogs instead of the out of the box cards that shop with PVA and that render multiple choice prompts to the user in a horizontal (carousel) layout. I wish there was an option to just specify I want to layout the multiple choice prompts vertically like a hero card instead of horizontally like a carousel. :-(

fausttiger007 commented 1 year ago

You can also add your own settings... to be read into bot i.e. add a setting value to your appsetting.json in your bot, and you can read it via setting.xxxx.yyy (or ${setting.xxxx.yyy} ...

JonathanFingold commented 1 year ago

@itprofessional68 - closing this issue as it looks like most of your questions have been addressed. Please open a new issue if you have more questions.