Search code examples
botframeworkbot-framework-composer

Syntax for using LG templates/functions within adaptive expressions in Bot Framework Composer


I want to set a property using an expression as follows: =json(InputCard(dialog.msgs))

where InputCard() is an LG template (shown below). I get the following error:

Expression evaluation resulted in an error. Expression: "=json(InputCard(dialog.msgs))". Error: InputCard does not have an evaluator, it's not a built-in function or a custom function.

Is there a syntax which allows me to use an LG template in an adaptive expression or is this not possible? Thanks for any suggestions.

In case it is relevant, the definition of #InputCard is as follows:

# InputCard(msgs)
- ```
{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.2",
  "body": [
  {
    "type": "FactSet",
    "facts": [
      ${join(foreach(msgs,item,FactGen(item.key,item.value)), ',' ) } 
    ]
  },
    {
      "type": "Input.Text",
      "id": "reply",
      "placeholder": "Enter your reply here"
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Submit",
      "data": ${json(msgs)}
    }
  ],
  "msteams": {"width": "Full"}
}


Solution

  • I suggest you to install the Bot Framework Adaptive Tools for Visual Studio Code.

    Once you do you'll get highlighting and a message like this when you hover the squiggly line:

    enter image description here

    I guess the problem is that you haven't used the namespace and exports LG options in the template where you define "FactGen" and "InputCard"

    UPDATE: Pasted the correct link above 😏