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

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}}

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.

Capturing Choice set values from the adaptive card

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
}
]

Specify a blank value in a custom PickList field via api

How can I specify an empty value for a custom-field
https://developer.bigcommerce.com/api-reference/customer-subscribers/v3-customers-api/customer-form-fields/customerformfieldvalueput
PUT https://api.bigcommerce.com/stores/:store_id/v3/customers/form-field-values
[
{
"name": "MyCustomField",
"address_id": 395,
"value": ""
}
]
gives me this
{
"status": 422,
"title": "Create form field value failed.",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes",
"errors": {
"0.form_field_value": "Option '' does not exist in 'MyCustomField'"
}
}
I have also tried
"value": null
with result
"errors": {
"0.data": "Missing form-field value for form-field 'MyCustomField'"
}
"value": undefined
with result
{
"status": 400,
"title": "Input is invalid",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes",
"errors": {}
}
If the custom form field doesn't already exist on the store you're sending this call to, you'll see an error like "Form-field 'test' does not exist in the 'Customer' form". Once set to an existing field's name, I was able to successfully send a call like the one described here.
Are you also creating the custom form field programmatically? You might need to add logic so that this call is only run after the field is created.

Querying BigQuery Events data in PowerBI

Hi I have analytics events data moved from firebase to BigQuery and need to create visualization in PowerBI using that BigQuery dataset. I'm able to access the dataset in PowerBI but some fields are in array type I generally use UNNEST while querying in console but how to run the query inside PowerBI. Is there any other option available? Thanks.
Table In BigQuery
What we did until the driver fully supports arrays is to flatten in a view: create a view in bigquery with UNNEST() and query that in PBI instead.
You might need to Transform(parse Json into columns/rows) your specific column in your case event_params
So I have below Json as example for you.
{
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
}
I had this json added to my table. currently it has only 1 column
Now I go to Edit queries and go on Transform Tab, there you find Parse, In my case I have Json
When you parse as Json you will have expandable column
Now click on expanding it and sometimes it asks for expand to new row.
Finally you will have such a Table

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