Capturing Choice set values from the adaptive card - anypoint-studio

I was wondering how can I capture the selected choice sets values in the adaptive card. Is there a way to capture the response after hitting the Action.submit button?
Below you can see, the selection is an array that shows the titles based on the initial logic and creates a Choices array
"body": [{
"type": "TextBlock",
"text": "select the recordings you want to delete"
},
{
"type": "Input.ChoiceSet",
"isMultiSelect": true,
"id": "myColor",
"style": "compact",
"value": "1",
"choices": vars.selection
}
]

Related

Shopify section schema: different content for each present block

I'm just starting out with Shopify development, and I'm creating a custom section called USP Banner which has a single block type called column that can be added up to 4 times; and that column just has one text and one richtext field within it. The content of each column is identical on every page, but the section can appear in different places depending on the page itself.
I've given the column default values for the text & richtext and added the 4 columns that will be used into the presets definition of the schema; however because it's just the same column x 4, each column has the same content 4 times. What I'm aiming for is that when you add the section to any page, it prefills each column with different content.
I read through the Shopify docs and all I found was some vague allusion to having a settings object within the block presets, but I can't find any examples of that anywhere. I also found an old SO answer stating that presets can't contain default content.
Is there an easy way to add default content to repeating blocks within a section?
Although it's not made clear in the official docs, you can set default values for repeated blocks in the presets; but whereas the settings when defining the blocks are arrays of objects, the settings within the preset blocks are objects where each pre-determined field value uses the field's unique ID as its key. For example, a typical section schema might look like:
{% schema %}
{
"name": "USP Banner",
"blocks": [
{
"type": "column",
"name": "Column",
"limit": 4,
"settings": [
{
"type": "text",
"id": "heading",
"label": "Heading",
},
{
"type": "richtext",
"id": "text",
"label": "Text",
}
]
}
],
"presets": [
{
"name": "USP Banner",
"blocks": [
{
"type": "column"
},
{
"type": "column"
}
]
}
]
}
{% endschema %}
...so to create preset values for each block, we simply add settings to the preset definition like so:
"presets": [
{
"name": "USP Banner",
"blocks": [
{
"type": "column",
"settings": {
"heading": "Remarkable Value",
"text": "<p>Never knowingly undersold</p>"
}
},
{
"type": "column",
"settings": {
"heading": "5-Year Warranty",
"text": "<p>We're that confident in our products</p>"
}
}
]
}
]
...where the key for each field (heading & text in this case) is the ID of the defined fields in the blocks section at the top of the schema.

Remove user selected item from the list in SAP conversational AI Chatbot

I am working on a chatbot project where I have to create a dynamic list option. There is a list of 15 Items (first step). When user selects one, selected item should be removed from the list. After that It will return to first step (list) and will display only 14 items. Where is the issue in step 3?
Step 1: I have created a "item_list" in the memory field of one skill.
[{"item": "product_1", "value": 5},{"item": "product_2", "value": 6},{"item": "product_3", "value": 4}]
Step 2: Choose custom list and enter the following script in the same skill.
{
"type": "list",
"delay": "",
"content": {
"elements": [
{{#eachJoin memory.item_list}}
{
"title": "{{this.item_list.item}}",
"subtitle": "{{this.item_list.value}}",
"imageUrl": "",
"status": "",
"statusState": "<''/none/information/error/success/warning>",
"description": "",
"buttons": [
{
"title": "{{this.item_list.item}}",
"value": "{{this.item_list.item}}",
"type": "postback"
}
]
}{{/eachJoin}}
]
}
}
Step 3: In another skill, set memory field where the user input is stored and set another memory "item_list" to match the user input within the array value to remove it from the item_list. For this, I have entered the following script. But there is some problem with that script. How can I remove the item from the array?
{{#inArray memory.item_list.title memory.user_input.raw}} "{{remove memory.item_list memory.user_input.raw}}" {{else}} "{{memory.lists}}"{{/inArray}}

Great Expectations Row Based Dimensions

I have data like this:
[ {
"name": "Apple",
"price": 1,
"type": "Food"
},
{
"name": "Apple",
"price": 0.90,
"type": "Food"
},
{
"name": "Apple",
"price": 1000,
"type": "Computer"
},
{
"name": "Apple",
"price": 900,
"type": "Computer"
}
]
Using the Great Expectations automatic profile, a valid range for price would be 0.90 to 1,000. Is it possible to have it slice on the type dimension, so food would be 0.90 to 1 and computer would be 900 to 1000? Or would I need to transform the data first using dbt? I know the column that will create the dimension, but I don't know the particular values.
Also, same question on differences between rows. Like if they had a timestamp, instead of 900 to 1000, it validates -100 for the change in value.
I used this approach to first load the data in a pandas data frame:
https://discuss.greatexpectations.io/t/how-can-i-use-the-return-format-unexpected-index-list-to-select-row-from-a-pandasdataset/70/2

Append to Specific Array Index from another table dynamically SQL Server

I have a json string that I need to modify
{"RecordCount":3,"Top":10,"Skip":0,"SelectedSort":"Seed asc","value":[{"AccountProductListId":22091612871138,"Name":"April 4th 2018","AccountId":256813438078643,"IsPublic":false,"Comment":"Test order sheet","Quantity":3},{"AccountProductListId":166305848801939,"Name":"test","AccountId":256813438078643,"IsPublic":false,"Comment":"","Quantity":1},{"AccountProductListId":21177711287586,"Name":"Test Order sheet","AccountId":256813438078643,"IsPublic":true,"Comment":"the very first sheet","Quantity":2}]}
Inside value the array looks like this:
"value": [{
"AccountProductListId": 22091612871138,
"Name": "April 4th 2018",
"IsPublic": false,
"Comment": "Test order sheet",
"Quantity": 3
}, {
"AccountProductListId": 166305848801939,
"Name": "test",
"IsPublic": false,
"Comment": "",
"Quantity": 1
}, {
"AccountProductListId": 21177711287586,
"Name": "Test Order sheet",
"IsPublic": true,
"Comment": "the very first sheet",
"Quantity": 2
}],
What I need to do is append some data from another table:
AccountProductListId ProductID
21177711287586 97096131867163|32721319938943
22091612871138 97096131867163|145461009584740|130005306921282
166305848801939 8744071222157
As you can see the AccountProductListId is already in the JSON result so I should know which array it should go to. The only problem is I don't know the syntax to merge the ProductID data into its specific array index. The JSON array could have more than 3 items.
Essentially ending up with something like this:
"value": [{
"AccountProductListId": 22091612871138,
"Name": "April 4th 2018",
"IsPublic": false,
"Comment": "Test order sheet",
"Quantity": 3,
"ProductID": "97096131867163|145461009584740|130005306921282"
}, {
"AccountProductListId": 166305848801939,
"Name": "test",
"IsPublic": false,
"Comment": "",
"Quantity": 1,
"ProductID": "8744071222157"
}, {
"AccountProductListId": 21177711287586,
"Name": "Test Order sheet",
"IsPublic": true,
"Comment": "the very first sheet",
"Quantity": 2,
"ProductID": "97096131867163|32721319938943"
}],
Any information would be greatly appreciated. Thanks.
Process with SQL Server
Prior to SQL Server 2016, there is not in-built support to read or write JSON.
Starting SQL Server 2016, you can use OPENJSON rowset function to read JSON and FOR JSON clause to write JSON.
See https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server
The approach would be to use OPENJSON to read the JSON string as a rowset, join it with the table to pickup ProductID and use FOR JSON to convert back to JSON.
Process outside SQL Server
Depending on your situation, it might be simpler to parse JSON outside SQL Server. If going that route, then you could
Collect all the AccountProductListIDs from the parsed JSON
Send the collected id to SQL Server via a stored procedure that takes a TVP input and outputs the AccountProductListID -> ProductID mapping
Inject the ProductIDs into JSON object and serialize back to string

How do i make custom reordering for products in collection in shopify

How do i make custom reorder for products in collection in shopify. i mean for exapmle i have 'test' collection and i want to reorder products in 'test' collection by using product tag i mean i put some tags like 'firstshowup' in some product in 'test' collection so when customer click 'test' collection customer see products which have 'firstshowup' tag first and then see the rest so what iam trying here is reordering using custom reordering not using like order by bestseller or allpabetically or date created s.t
thank you so much guys in advance
Your collection will be made up of Collect objects, which have a position attribute. Assuming you're using a CustomCollection, you can modify the position of the Collects by updating the CustomCollection: http://api.shopify.com/customcollection.html#update
From the examples, to update a collection, you can use:
PUT /admin/custom_collections/#{id}.json
With the following payload:
{
"custom_collection": {
"body_html": "<p>The best selling ipod ever</p>",
"handle": "ipods",
"id": 841564295,
"published_at": "2008-02-01T19:00:00-05:00",
"sort_order": "manual",
"template_suffix": null,
"title": "IPods",
"updated_at": "2008-02-01T19:00:00-05:00",
"image": {
"created_at": "2012-12-11T12:01:29-05:00",
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/collections/ipod_nano_8gb.jpg?0"
},
"collects": [
{
"product_id": 921728736,
"position": 1
},
{
"id": 841564295,
"position": 2
}
]
}
}