Tips of Building Custom Action in Bot Framework Composer V2
Published May 05 2022 07:51 PM 3,930 Views
Microsoft

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:

 

  1. 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.

 

  1. 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.

 

   "runtimeSettings": {

 

    …….

   

    "components": [

      {

        "name": "MyCustomActionDialog"

      }

    ],

 

This is easily to be ignored because it is a sub step in the official document.

 

  1. 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

 

To:

 

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:

 

 .\update-schema.ps1
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...

 

  1. 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!

1 Comment
Co-Authors
Version history
Last update:
‎May 05 2022 08:08 PM
Updated by: