在 Bot Framework Composer 中将简单数组添加到 JSON 有效负载

发布于 2025-01-16 22:06:00 字数 948 浏览 1 评论 0原文

我有一个简单的问题,在使用 Bot Framework Composer 时,我无法在 json 负载中插入数组来调用图形 api 来更新用户配置文件。

示例:

Step1. 我创建了一个属性 Conversation.UpdatedSkills,它包含以下值

["SharePoint","Dotnet","Analytics"]

现在我想为 MS Graph 服务构建 JSON 对象,工作示例有效负载如下所示。

{
   "skills":["SharePoint","Dotnet","Analytics"]
}

步骤2。现在要动态构建此 JSON,我需要在“发送 HTTP 请求”活动中将正文作为 JSON 对象传递,并且我有以下代码来生成有效负载。

{
    "skills":"${conversation.UpdatedSkills}"
}

Step2 的输出看起来像这样。

{

    “skills”: “[\r\n “SharePoint”,\r\n “Dotnet”,\r\n “Analytics”\r\n]”

}

所需的 JSON 是这样的:

 {
       "skills":["SharePoint","Dotnet","Analytics"]
 }

我的问题是,如何从步骤 1 传递我的数组,以便它创建在服务中工作的 json 对象。使用步骤 2 创建的对象不是服务采用的正确对象。

有什么想法吗?

我尝试了不同的字符串操作,但我认为这是基本的,并且必须有一些东西。

I have a simple problem where I am not able to insert an array in json payload to call graph api to update user profile while using Bot Framework Composer.

Example:

Step1. I created a property Conversation.UpdatedSkills which holds following value

["SharePoint","Dotnet","Analytics"]

Now I want to build JSON object for MS Graph service and working sample payload looks like this.

{
   "skills":["SharePoint","Dotnet","Analytics"]
}

Step2. Now to build this JSON dynamically, I need pass body as JSON Object in Send an HTTP Request activity and I have folllowing code to generate payload.

{
    "skills":"${conversation.UpdatedSkills}"
}

The output from Step2 looks something like this.

{

    “skills”: “[\r\n “SharePoint”,\r\n “Dotnet”,\r\n “Analytics”\r\n]”

}

DESIRED JSON WAS THIS:

 {
       "skills":["SharePoint","Dotnet","Analytics"]
 }

My question is, How do I pass my array from step 1 such a way so that it creates json object that works in service. The object created using step 2 is not the right object that service takes.

Any idea?

I tried different string manipulations but I think this is basic and there has to be something.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏の忆 2025-01-23 22:06:00

不要使用字符串插值 ${ },而是使用表达式 (=)。对于上面的示例,它应该是:

{
  "skills": "=conversation.UpdatedSkills"
}

Don't use the string interpolation ${ }, but use an expression (=). For your example above, it should be:

{
  "skills": "=conversation.UpdatedSkills"
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文