Skip to main content

Notifications

Power Platform Community / Forums / General / Bot Framework // Exclu...
General
Answered

Bot Framework // Excluding part of JSON?

Posted on by 71

Happy Friday All!

 

So I made an adaptive carousel card on Teams that shows the address book from the 365.  However it also shows the admin accounts.  Currently, I got to hide the admin account using another card however I want to exclude those from the carousel all together:   

nk1ng_7-1631289222965.png

nk1ng_3-1631285755039.png

 

I am struggling with the code.  I know somewhere I need to have the IF statement here not the addressBookCard but I am stuck with the syntax:

   # addressBook(resultArrObj)
   [Activity
     name = Global
     Attachments = ${foreach (resultArrObj, x, json(addressBookCard(x))) }
     AttachmentLayout = carousel
   ]
 
Currently:
Attachment-> (bob's card #1), (hidden admin bob's card #2), (bob's card #3) with the if statement on addressBookCard
Need to have:
Attachment-> (bob's card #1), (bob's card #3) with the if statement in addressBook in theory anyways, if that makes sense?

Here is the whole bot responses code to understand what I am saying:

 

 

[import](common.lg)

> Begin AddressBook
#addressBookCard(resultObj)
-IF: ${ contains(resultObj.mailNickname,'admin') }
- ```
{
 "type": "AdaptiveCard",
 "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
 "version": "1.2",
 "body": [
 {
 "type": "Container",
 "items": [
 {
 "type": "TextBlock",
 "text": "Hidden Account",
 "wrap": true,
 "horizontalAlignment": "Center",
 "weight": "Lighter",
 "color": "Accent",
 "isSubtle": true,
 "height": "stretch"
 }
 ],
 "height": "stretch",
 "minHeight": "230px",
 "verticalContentAlignment": "Center"
 }
 ]
}
```
- ELSE:
- ```
{
 "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
 "type": "AdaptiveCard",
 "version": "1.2",
 "body": [
 {
 "type": "ColumnSet",
 "columns": [
 {
 "type": "Column",
 "width": "auto",
 "items": [
 {
 "type": "Image",
 "size": "Stretch",
 "url": "https://redacted.sharepoint.com/_layouts/15/userphoto.aspx?size=S&username=${resultObj.Mail}",
 "style": "Person",
 "selectAction": {
 "type": "Action.OpenUrl",
 "url": "https://redacted.sharepoint.com/_layouts/15/userphoto.aspx?size=S&username=${resultObj.Mail}"
 },
 "width": "60px",
 "height": "60px"
 }
 ]
 },
 {
 "type": "Column",
 "width": "stretch",
 "items": [
 {
 "type": "TextBlock",
 "text": "${resultObj.displayName} (${resultObj.mailNickname})",
 "horizontalAlignment": "Right",
 "isSubtle": true,
 "wrap": true,
 "size": "Large",
 "fontType": "Default",
 "weight": "Bolder"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.jobTitle}",
 "horizontalAlignment": "Right",
 "spacing": "None",
 "size": "Medium",
 "color": "Accent",
 "wrap": true
 }
 ],
 "height": "stretch"
 }
 ]
 },
 {
 "type": "ColumnSet",
 "separator": true,
 "spacing": "Medium",
 "columns": [
 {
 "type": "Column",
 "width": "stretch",
 "items": [
 {
 "type": "TextBlock",
 "text": "${resultObj.department}",
 "horizontalAlignment": "Right",
 "height": "stretch"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.City}",
 "horizontalAlignment": "Right",
 "spacing": "Small",
 "height": "stretch"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.OfficeLocation}",
 "horizontalAlignment": "Right",
 "spacing": "Small",
 "height": "stretch"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.Mail}",
 "wrap": true,
 "horizontalAlignment": "Right",
 "spacing": "Small"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.BusinessPhones}",
 "wrap": true,
 "spacing": "Small",
 "horizontalAlignment": "Right"
 },
 {
 "type": "TextBlock",
 "text": "${resultObj.mobilePhone}",
 "horizontalAlignment": "Right",
 "spacing": "Small",
 "height": "stretch"
 }
 ]
 }
 ]
 },
 {
 "type": "Container",
 "separator": true,
 "items": [
 {
 "type": "ColumnSet",
 "columns": [
 {
 "type": "Column",
 "width": "auto",
 "items": [
 {
 "type": "TextBlock",
 "wrap": true
 }
 ]
 }
 ],
 "isVisible": false
 }
 ]
 }
 ]
}
```

# addressBook(resultArrObj)
[Activity
name = Global
Attachments = ${foreach (resultArrObj, x, json(addressBookCard(x))) }
AttachmentLayout = carousel
]
# SendActivity_k1Z42T()
- ${addressBook(dialog.resultArrObj)}

 


and here an redacted JSON that I am passing through to SendActivity:

 

[
 {
	 "Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
	 "AccountEnabled":true,
	 "BusinessPhones":"1-555-555-5555",
	 "City":"Redacted",
	 "CompanyName":"Redacted",
	 "Department":"IT Dept",
	 "DisplayName":"Bob Smith",
	 "GivenName":"Bob",
	 "JobTitle":"Principal, IT Dept",
	 "Mail":"Bob.Smith@redacted.com",
	 "MailNickname":"bobsmith",
	 "mobilePhone":"1-555-555-5555",
	 "OfficeLocation":"01.01 Redacted",
	 "PostalCode":"55555",
	 "Surname":"Smith",
	 "TelephoneNumber":"1-555-555-5555",
	 "UserPrincipalName":"Bob.Smith@redacted.com"
 },
 {
	 "Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
	 "AccountEnabled":true,
	 "BusinessPhones":"",
	 "City":"Redacted",
	 "CompanyName":"Redacted",
	 "Department":"IT Dept",
	 "DisplayName":"Bob Smith (Admin O365)",
	 "GivenName":"Bob",
	 "JobTitle":"Principal",
	 "Mail":"bobsmithadmin@redacted.onmicrosoft.com",
	 "MailNickname":"bobsmithadmin",
	 "mobilePhone":"1-555-555-5555",
	 "OfficeLocation":"01.01 Redacted",
	 "PostalCode":"55555",
	 "Surname":"Smith",
	 "TelephoneNumber":"1-555-555-5555",
	 "UserPrincipalName":"bobsmithadmin@redacted.onmicrosoft.com"
 },
 {
	 "Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
	 "AccountEnabled":true,
	 "BusinessPhones":"1-555-555-5555",
	 "City":"Redacted",
	 "CompanyName":"Redacted",
	 "Department":"IT Dept",
	 "DisplayName":"Bob Smith",
	 "GivenName":"Bob",
	 "JobTitle":"Principal, IT Dept",
	 "Mail":"Bob.Smith@redacted.com",
	 "MailNickname":"bobsmith",
	 "mobilePhone":"1-555-555-5555",
	 "OfficeLocation":"01.02 Redacted",
	 "PostalCode":"55555",
	 "Surname":"Smith",
	 "TelephoneNumber":"1-555-555-5555",
	 "UserPrincipalName":"Bob.Smith@redacted.com"
 }
]

 

 

Let me know and if you can help!
Categories:
  • nk1ng Profile Picture
    nk1ng 71 on at
    Re: Bot Framework // Excluding part of JSON?

    Nevermind, just needed to grab from the body('Filter_array').

    nk1ng_1-1631541438720.png

     

    Thank you again!

    -n

  • nk1ng Profile Picture
    nk1ng 71 on at
    Re: Bot Framework // Excluding part of JSON?

    Thank you so much, Expiscornvus!  Works perfectly except when I try cast into a string, I get the original array?

    nk1ng_0-1631541086866.png

     

     

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 1,667 on at
    Re: Bot Framework // Excluding part of JSON?

    Hi @nk1ng,

     

    I still have to figure out how we can do this in code.

     

    However, looking at your previous threads you are using a search for users action in Power Automate flow, correct?

     

    If so, you could use this filter array action in the flow to exclude the admin accounts from your array.

     

    nicknamedoesnotendwithadmin.png

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
renatoromao Profile Picture

renatoromao 6,459

#2
Pstork1 Profile Picture

Pstork1 1,954

#3
Expiscornovus Profile Picture

Expiscornovus 1,667