Custom Action is the important method to extend Bot App functionalities through C# in Bot Framework Composer for the low code bot solution. Using it, we can create complicated actions for our bots, including re-constructing turn activity results, image converting, math algorithms, adaptive responses to different channels, etc. This official article provides good sample steps to build a simple Customer Action:
Create custom actions in Bot Framework Composer | Microsoft Docs
However there are still several key parts should be paid attention to. The Custom Action cannot work as expected if we ignore them. Here are details:
- The name of the .schema file must match the Kind variable defined in the <MyCustomActionDialog>.cs file exactly.
And it is Case Sensitive.
This has been pointed out in the article. Usually developers will not miss this point.
- Don’t forget to modify the appsettings.json in the bot composer project. Otherwise, after adding the Custom Action in Canvas, and run this bot app, you will see this error:
dialog error: Type <MyCustomActionDialog> not registered in factory.
In the appsettings.json file of the bot project (located at YourBotApp\settings)to include the MyCustomActionDialog in the runtimeSettings/components array.
This is easily to be ignored because it is a sub step in the official document.
- In Bot Framework Composer V2.1.2, when merge the custom schema with powershell update-schema.ps1, need to modify update-schema.ps1, change its statement from:
bf dialog:merge "*.schema" "!**/sdk-backup.schema" "*.uischema" "!**/sdk-backup.uischema" "!**/sdk.override.uischema" "!**/generated" "../*.csproj" "../package.json" -o $SCHEMA_FILE
bf dialog:merge "*.schema" "!**/sdk-backup.schema" "*.uischema" "!**/sdk-backup.uischema" "!**/sdk.override.uischema" "!../generated" "!../dialogs/imported" "../*.csproj" "../package.json" -o $SCHEMA_FILE
Otherwise, you will see similar errors during merging schema:
Running schema merge.
Finding component files
Error conflicting definitions of CancelDialog.dialog
For more details of this issue, refer to:
Custom actions merge schema failed error · Issue #8501 · microsoft/BotFramework-Composer (github.com...
- After running the update-schema.ps1, remember to remove MyCustomActionDialog.schema and the Imported folder from the ..\schemas Folder. Otherwise will see some errors like:
Deactivated action. Components of $kind "Microsoft.AdaptiveDialog" are not supported
For details of the problem, refer to this github issue:
Error when implimenting a custom action: Components of $kind "Microsoft.AdaptiveDialog" are not supp...
With above tips, you should be able to successfully build Custom Action for latest Bot Framework Composer Project.
Happy Bot Development!