Malformed response in Actions On Google - dialogflow-es

Was trying to build a transactional Google Assistant App and framed the request Order object as following:
{
"#type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
"orderOptions": {
"requestDeliveryAddress": false
},
"paymentOptions": {
"googleProvidedOptions": {
"prepaidCardDisallowed": false,
"supportedCardNetworks": ["VISA", "AMEX", "DISCOVER", "MASTERCARD"],
"tokenizationParameters": {
"tokenizationType": "PAYMENT_GATEWAY",
"parameters": {
"gateway": "stripe",
"stripe:publishableKey": "pk_live_KEY",
"stripe:version": "2019-05-16"
}
}
}
},
"proposedOrder": {
"createTime": "2019-08-11T12:18:36-04:00",
"lastUpdateTime": "2019-08-11T12:18:36-04:00",
"merchantOrderId": "248276353077",
"userVisibleOrderId": "248276353077",
"transactionMerchant": {
"id": "shopifystore.myshopify.com",
"name": "Shoe Store"
},
"contents": {
"lineItems": [{
"name": "Amla Shots",
"id": "29051889385525",
"priceAttributes": {
"type": "REGULAR",
"name": "Item Price",
"amount": {
"currencyCode": "USD",
"amountInMicros": "5000000"
},
"state": "ACTUAL",
"taxIncluded": false
},
"purchase": {
"quantity": "1"
},
"description": ""
}, {
"name": "Amla Shots",
"id": "29051889418293",
"priceAttributes": {
"type": "REGULAR",
"name": "Item Price",
"amount": {
"currencyCode": "USD",
"amountInMicros": "10000000"
},
"state": "ACTUAL",
"taxIncluded": false
},
"purchase": {
"quantity": "1"
},
"description": ""
}]
},
"buyerInfo": {
"email": "123#gmail.com",
"firstName": "123",
"lastName": "123",
"displayName": "123 123"
},
"priceAttributes": [{
"type": "TOTAL",
"name": "Total Price",
"state": "ESTIMATE",
"amount": {
"currencyCode": "USD",
"amountInMicros": "15990000"
},
"taxIncluded": true
}, {
"type": "TAX",
"name": "Tax",
"state": "ESTIMATE",
"amount": {
"currencyCode": "USD",
"amountInMicros": "990000"
},
"taxIncluded": true
}, {
"type": "SUBTOTAL",
"name": "Subtotal",
"state": "ESTIMATE",
"amount": {
"currencyCode": "USD",
"amountInMicros": "15000000"
}
}],
"termsOfServiceUrl": "https://example.com",
"note": "Powered by Example"
}
}
The error message that was showing:
MalformedResponse: Failed to parse Dialogflow response into
AppResponse because of invalid platform response: Tried to parse data
from system intent but failed
Where in the JSON is there a mistake?

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "systemIntent": {
        "intent": "actions.intent.TRANSACTION_DECISION",
        "data": {
          <add your above JSON here>
          }
        }
      }
    }
  }
}

Related

How set desired and reported properties for device twin in IoT Plug and Play DTDL model

I have this dtdl model I upload to local folder in IoT Plug and Play v0.15.4.0 (prior version behaviour is the same):
{
"#id": "dtmi:com:sergio:devkit;1",
"#type": "Interface",
"#context": [
"dtmi:dtdl:context;2"
],
"displayName": "Machine Part -v1",
"description": "Machine Part data",
"contents": [
{
"#type": "Property",
"name": "telemetryInterval",
"displayName": "telemetryInterval",
"description": "The time interval of this data",
"schema": "double",
"writable": true
},
{
"#type": "Property",
"name": "PartId",
"displayName": "PartId",
"description": "The unique id of the machine part",
"writable": true,
"schema": "string"
},
{
"#type": "Property",
"name": "Alert",
"displayName": "Alert",
"description": "whether or not this machine part needs maintenance",
"writable": true,
"schema": "boolean"
},
{
"#type": "Property",
"name": "ledState",
"displayName": "LED state",
"description": "Returns the current state of the onboard LED.",
"writable": true,
"schema": "boolean"
},
{
"#type": "Telemetry",
"name": "Description",
"schema": "string"
},
{
"#type": "Telemetry",
"name": "Code",
"schema": "integer"
},
{
"#type": "Telemetry",
"name": "Temperature",
"displayName": "Temperature",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "Humidity",
"displayName": "Humidity",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "pressure",
"displayName": "Pressure",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "magnetometerX",
"displayName": "Magnetometer X / mgauss",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "magnetometerY",
"displayName": "Magnetometer Y / mgauss",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "magnetometerZ",
"displayName": "Magnetometer Z / mgauss",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "accelerometerX",
"displayName": "Accelerometer X",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "accelerometerY",
"displayName": "Accelerometer Y",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "accelerometerZ",
"displayName": "Accelerometer Z",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "gyroscopeX",
"displayName": "Gyroscope X",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "gyroscopeY",
"displayName": "Gyroscope Y",
"schema": "double"
},
{
"#type": "Telemetry",
"name": "gyroscopeZ",
"displayName": "Gyroscope Z",
"schema": "double"
}
]
}
My expectation is that because properties ledState and Alert properties are writeable, these should be both reported and desired properties. However the IoT Hub Device in Azure portal (see below) shows them differently and I don't know why. How do I set the properties in the DTDL model I upload to IoT P&P to be reported or desired?
{
"deviceId": "mymxchip",
"etag": "AAAAAAAAAAk=",
"deviceEtag": "NDU1NDk0NDM4",
"status": "enabled",
"statusUpdateTime": "0001-01-01T00:00:00Z",
"connectionState": "Connected",
"lastActivityTime": "2023-01-09T07:26:48.611708Z",
"cloudToDeviceMessageCount": 0,
"authenticationType": "sas",
"x509Thumbprint": {
"primaryThumbprint": null,
"secondaryThumbprint": null
},
"modelId": "dtmi:com:sergio:devkit;1",
"version": 164,
"properties": {
"desired": {
"telemetryInterval": 5,
"Alert": true,
"$metadata": {
"$lastUpdated": "2023-01-08T07:27:01.9659284Z",
"$lastUpdatedVersion": 9,
"telemetryInterval": {
"$lastUpdated": "2023-01-08T06:54:11.9502921Z",
"$lastUpdatedVersion": 8
},
"Alert": {
"$lastUpdated": "2023-01-08T07:27:01.9659284Z",
"$lastUpdatedVersion": 9
}
},
"$version": 9
},
"reported": {
"deviceInformation": {
"__t": "c",
"manufacturer": "MXCHIP",
"model": "AZ3166",
"swVersion": "1.0.0",
"osName": "Azure RTOS",
"processorArchitecture": "Arm Cortex M4",
"processorManufacturer": "STMicroelectronics",
"totalStorage": 1024,
"totalMemory": 128
},
"ledState": false,
"telemetryInterval": {
"ac": 200,
"av": 1,
"value": 5
},
"$metadata": {
"$lastUpdated": "2023-01-09T07:28:26.0068306Z",
"deviceInformation": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z",
"__t": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"manufacturer": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"model": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"swVersion": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"osName": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"processorArchitecture": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"processorManufacturer": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"totalStorage": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
},
"totalMemory": {
"$lastUpdated": "2023-01-09T07:28:25.4599426Z"
}
},
"ledState": {
"$lastUpdated": "2023-01-09T07:28:25.7411971Z"
},
"telemetryInterval": {
"$lastUpdated": "2023-01-09T07:28:26.0068306Z",
"ac": {
"$lastUpdated": "2023-01-09T07:28:26.0068306Z"
},
"av": {
"$lastUpdated": "2023-01-09T07:28:26.0068306Z"
},
"value": {
"$lastUpdated": "2023-01-09T07:28:26.0068306Z"
}
}
},
"$version": 155
}
},
"capabilities": {
"iotEdge": false
}
}
You're correct that a DTDL writable property will appear as both a reported and desired property in the device twin. However, this is dependant and the behavior of the device.
If you set a desired property using a service API, that updates the desired property value in the device twin. The device should then send an Ack when it's received and processed the desired property - in your example above, it looks as if the device has done this for the telemetryInterval property. The device hasn't acknowledged the Alert desired property update.
When the device sends a reported property, the device twin is updated with the value sent by the device. In the example above, the device has sent deviceInformation, ledState, and telemetryInterval reported properties. The telemetryInterval was sent in response to a desired property.
You can find more details here:
https://learn.microsoft.com/en-us/azure/iot-develop/concepts-convention#writable-properties
https://learn.microsoft.com/en-us/azure/iot-develop/concepts-developer-guide-device#writable-properties (device code samples in multiple languages)
To following samples for a thermostat device all illustrate how to follow the PnP conventions for writable properties:
https://github.com/Azure/azure-iot-sdk-csharp/tree/main/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat
https://github.com/Azure/azure-iot-sdk-java/tree/main/device/iot-device-samples/pnp-device-sample
https://github.com/Azure/azure-iot-sdk-node/tree/main/device/samples
https://github.com/Azure/azure-iot-sdk-python/tree/main/samples/pnp

Need to get data from fixture JSON

I am struggling hard since yesterday getting the data from JSON, I don't understand why the fixture is not accessible. When I tried to get the ID, it gives me an error saying id isn't defined.
This gives me an error saying ID is not defined:
res.send(data.response["fixture"].id)
This code returns nothing:
res.send(data.response.fixture);
This code gives me the JSON data:
res.send(data.response
My JSON data:
// 20220714200426
// http://localhost:9090/
[
{
"fixture": {
"id": 822924,
"referee": "Jhon Alexander Hinestroza Romana, Colombia",
"timezone": "UTC",
"date": "2022-07-15T01:10:00+00:00",
"timestamp": 1657847400,
"periods": {
"first": 1657847400,
"second": 1657851000
},
"venue": {
"id": 375,
"name": "Estadio Manuel Murillo Toro",
"city": "Ibagué"
},
"status": {
"long": "Second Half",
"short": "2H",
"elapsed": 90
}
},
"league": {
"id": 239,
"name": "Primera A",
"country": "Colombia",
"logo": "https://media.api-sports.io/football/leagues/239.png",
"flag": "https://media.api-sports.io/flags/co.svg",
"season": 2022,
"round": "Clausura - 2"
},
"teams": {
"home": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png",
"winner": true
},
"away": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png",
"winner": false
}
},
"goals": {
"home": 2,
"away": 0
},
"score": {
"halftime": {
"home": 0,
"away": 0
},
"fulltime": {
"home": null,
"away": null
},
"extratime": {
"home": null,
"away": null
},
"penalty": {
"home": null,
"away": null
}
},
"events": [
{
"time": {
"elapsed": 1,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 13398,
"name": "Y. Congo"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 26,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 13592,
"name": "T. Gutierrez"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 27,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 13304,
"name": "B. Rovira"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 40,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 13592,
"name": "T. Gutierrez"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Red Card",
"comments": null
},
{
"time": {
"elapsed": 56,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": null,
"name": "O. Acosta"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 59,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 283830,
"name": "L. Riascos"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 61,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 13348,
"name": "L. Miranda"
},
"assist": {
"id": null,
"name": null
},
"type": "Var",
"detail": "Goal Disallowed - offside",
"comments": null
},
{
"time": {
"elapsed": 64,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 10328,
"name": "Y. Gonzalez"
},
"assist": {
"id": null,
"name": "O. Acosta"
},
"type": "subst",
"detail": "Substitution 1",
"comments": null
},
{
"time": {
"elapsed": 66,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 6632,
"name": "A. Renteria"
},
"assist": {
"id": 13348,
"name": "L. Miranda"
},
"type": "subst",
"detail": "Substitution 1",
"comments": null
},
{
"time": {
"elapsed": 69,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 13596,
"name": "M. Rangel"
},
"assist": {
"id": 13298,
"name": "J. Lucumi"
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": {
"elapsed": 70,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 59887,
"name": "A. Gutierrez"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 72,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 13298,
"name": "J. Lucumi"
},
"assist": {
"id": 6632,
"name": "A. Renteria"
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": {
"elapsed": 78,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 31691,
"name": "A. Vuletich"
},
"assist": {
"id": 51135,
"name": "H. Mosquera"
},
"type": "subst",
"detail": "Substitution 2",
"comments": null
},
{
"time": {
"elapsed": 78,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 200150,
"name": "J. C. Caldera Alvis"
},
"assist": {
"id": 51165,
"name": "A. Rodriguez"
},
"type": "subst",
"detail": "Substitution 3",
"comments": null
},
{
"time": {
"elapsed": 82,
"extra": null
},
"team": {
"id": 1127,
"name": "Deportivo Cali",
"logo": "https://media.api-sports.io/football/teams/1127.png"
},
"player": {
"id": 200150,
"name": "J. C. Caldera Alvis"
},
"assist": {
"id": null,
"name": null
},
"type": "Card",
"detail": "Yellow Card",
"comments": null
},
{
"time": {
"elapsed": 84,
"extra": null
},
"team": {
"id": 1142,
"name": "Deportes Tolima",
"logo": "https://media.api-sports.io/football/teams/1142.png"
},
"player": {
"id": 59758,
"name": "A. Melendez"
},
"assist": {
"id": 35757,
"name": "Y. Orozco"
},
"type": "subst",
"detail": "Substitution 2",
"comments": null
}
]
},
{
"fixture": {
"id": 896998,
"referee": null,
"timezone": "UTC",
"date": "2022-07-15T02:00:00+00:00",
"timestamp": 1657850400,
"periods": {
"first": 1657850400,
"second": 1657854000
},
"venue": {
"id": 1087,
"name": "Estadio Universitario de Nuevo León",
"city": "San Nicolás de los Garza"
},
"status": {
"long": "Second Half",
"short": "2H",
"elapsed": 46
}
},
"league": {
"id": 927,
"name": "World Cup - Women - Qualification Concacaf",
"country": "World",
"logo": "https://media.api-sports.io/football/leagues/927.png",
"flag": null,
"season": 2022,
"round": "Semi-finals"
},
"teams": {
"home": {
"id": 1717,
"name": "Canada W",
"logo": "https://media.api-sports.io/football/teams/1717.png",
"winner": true
},
"away": {
"id": 1785,
"name": "Jamaica W",
"logo": "https://media.api-sports.io/football/teams/1785.png",
"winner": false
}
},
"goals": {
"home": 1,
"away": 0
},
"score": {
"halftime": {
"home": 1,
"away": 0
},
"fulltime": {
"home": null,
"away": null
},
"extratime": {
"home": null,
"away": null
},
"penalty": {
"home": null,
"away": null
}
},
"events": [
{
"time": {
"elapsed": 10,
"extra": null
},
"team": {
"id": 1785,
"name": "Jamaica W",
"logo": "https://media.api-sports.io/football/teams/1785.png"
},
"player": {
"id": null,
"name": "C. Swaby"
},
"assist": {
"id": null,
"name": "J. C. Pelaia-Hylton"
},
"type": "subst",
"detail": "Substitution 1",
"comments": null
},
{
"time": {
"elapsed": 18,
"extra": null
},
"team": {
"id": 1717,
"name": "Canada W",
"logo": "https://media.api-sports.io/football/teams/1717.png"
},
"player": {
"id": null,
"name": "J. Fleming"
},
"assist": {
"id": null,
"name": null
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
}
]
},
{
"fixture": {
"id": 868553,
"referee": null,
"timezone": "UTC",
"date": "2022-07-15T02:05:00+00:00",
"timestamp": 1657850700,
"periods": {
"first": 1657850700,
"second": null
},
"venue": {
"id": 1844,
"name": "Estadio Olímpico Carlos Iturralde Rivero",
"city": "Mérida"
},
"status": {
"long": "Halftime",
"short": "HT",
"elapsed": 45
}
},
"league": {
"id": 263,
"name": "Ascenso MX",
"country": "Mexico",
"logo": "https://media.api-sports.io/football/leagues/263.png",
"flag": "https://media.api-sports.io/flags/mx.svg",
"season": 2022,
"round": "Apertura - 3"
},
"teams": {
"home": {
"id": 2311,
"name": "Venados FC",
"logo": "https://media.api-sports.io/football/teams/2311.png",
"winner": true
},
"away": {
"id": 2308,
"name": "Celaya",
"logo": "https://media.api-sports.io/football/teams/2308.png",
"winner": false
}
},
"goals": {
"home": 2,
"away": 1
},
"score": {
"halftime": {
"home": 2,
"away": 1
},
"fulltime": {
"home": null,
"away": null
},
"extratime": {
"home": null,
"away": null
},
"penalty": {
"home": null,
"away": null
}
},
"events": [
{
"time": {
"elapsed": 11,
"extra": null
},
"team": {
"id": 2308,
"name": "Celaya",
"logo": "https://media.api-sports.io/football/teams/2308.png"
},
"player": {
"id": null,
"name": "D. Gonzalez"
},
"assist": {
"id": null,
"name": null
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": {
"elapsed": 17,
"extra": null
},
"team": {
"id": 2311,
"name": "Venados FC",
"logo": "https://media.api-sports.io/football/teams/2311.png"
},
"player": {
"id": null,
"name": "M. Perez"
},
"assist": {
"id": null,
"name": null
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": {
"elapsed": 36,
"extra": null
},
"team": {
"id": 2311,
"name": "Venados FC",
"logo": "https://media.api-sports.io/football/teams/2311.png"
},
"player": {
"id": 36091,
"name": "M. Perez"
},
"assist": {
"id": null,
"name": null
},
"type": "Goal",
"detail": "Normal Goal",
"comments": null
}
]
}
]
My Node.js code:
const express = require('express');
const Router = express.Router();//router will be used now to route
require('dotenv').config();
const fetch = require('cross-fetch');
const axios = require('axios');
const request = require('request');
const endpoint = 'fixtures';
Router.get('/', (req, res) => {
var options = {
method: 'GET',
url: `https://v3.football.api-sports.io/${endpoint}`,
qs: {live: 'all'},
headers: {
'x-rapidapi-host': 'v3.football.api-sports.io',
'x-rapidapi-key': `${process.env.API_KEY}`
}
};
request(options, function (error, resp, body) {
if (error) throw new Error(error);
const data = JSON.parse(body);
res.send(data.response);
});
})
module.exports = Router;
What I want is to access fixture ID and all other keys as well but I am not able to reach the fixture. Can anyone able to guide me on what's wrong I am doing?
From the json data response body above, data.response is an array of objects of multiple fixtures. So, data.response.fixture would always return undefined. To access a particular fixture, depending on what you want to do to with, you'd have to access the index of the response first. As such:
console.log(data.response[0].fixture)
this should return:
"fixture": {
"id": 822924,
"referee": "Jhon Alexander Hinestroza Romana, Colombia",
"timezone": "UTC",
"date": "2022-07-15T01:10:00+00:00",
"timestamp": 1657847400,
"periods": {
"first": 1657847400,
"second": 1657851000
},
"venue": {
"id": 375,
"name": "Estadio Manuel Murillo Toro",
"city": "Ibagué"
},
"status": {
"long": "Second Half",
"short": "2H",
"elapsed": 90
}
}
To access its id:
console.log(data.response[0].fixture.id)
The important thing is to access the properties through the array index of the element you want.

Cannot Add Sales Order with Payment thru REST API

I’m sending a Sales Order with Pre-Authorized Payment thru REST API in Acumatica. This works perfect in my local Acumatica instance. However, I can’t get it worked when switching to Acumatica.com and I’m getting this error “The order cannot be applied, the specified combination of the order type and order number cannot be found in the system.”. It works well when I remove the payment details.
<pre><code>
{
"BillToAddress": {
"AddressLine1": {
"value": "3153 Doctors Drive"
},
"AddressLine2": {
"value": ""
},
"City": {
"value": "Los Angeles"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "90017"
},
"State": {
"value": "CA"
},
"custom": {}
},
"BillToAddressOverride": {
"value": false
},
"BillToContact": {
"Attention": {
"value": "Mr."
},
"BusinessName": {
"value": "Gregory Luton"
},
"Email": {
"value": "gluton#hotmeal.com"
},
"Phone1": {
"value": "(310) 341-3975"
},
"custom": {}
},
"CreditHold": {
"value": false
},
"CustomerID": {
"value": "S000000001"
},
"CustomerOrder": {},
"Date": {
"value": "2021-06-02T13:42:02.22Z"
},
"Description": {
"value": ""
},
"Details": [
{
"ManualPrice": {
"value": true
},
"Amount": {
"value": 79.99
},
"DiscountAmount": {
"value": 0
},
"DiscountCode": {},
"DiscountPercent": {
"value": 0
},
"ExtendedPrice": {
"value": 79.99
},
"FreeItem": {
"value": false
},
"InventoryID": {
"value": "ELEHDD1"
},
"LineDescription": {
"value": "Lego 500 piece set"
},
"LineNbr": {
"value": 1
},
"ManualDiscount": {
"value": false
},
"OpenQty": {
"value": 1
},
"OrderQty": {
"value": 1
},
"RequestedOn": {
"value": "2021-06-02T13:42:02.22Z"
},
"Subitem": {
"value": ""
},
"UnbilledAmount": {
"value": 79.99
},
"UnitPrice": {
"value": 79.99
},
"UOM": {
"value": "EA"
},
"WarehouseID": {
"value": "WHOLESALE"
},
"rowNumber": 1,
"custom": {}
}
],
"Hold": {
"value": false
},
"OrderedQty": {
"value": 1
},
"OrderTotal": {
"value": 79.99
},
"OrderType": {
"value": "SO"
},
"Payments": [
{
"CardAccountNbr": {
"value": "CUSTOMPAYMC:S000000001"
},
"CashAccount": {
"value": "10600"
},
"CreditCardTransactionInfo": [
{
"AuthNbr": {
"value": "23456"
},
"NeedValidation": {
"value": false
},
"TranDate": {
"value": "2021-06-02T16:13:01.22Z"
},
"TranNbr": {
"value": "12345"
},
"TranType": {
"value": "Authorize Only"
},
"custom": {}
}
],
"Description": {
"value": "Payment for 006024"
},
"PaymentAmount": {
"value": 79.99
},
"PaymentMethod": {
"value": "CUSTOMPAYMC"
},
"ProcessingCenterID": {
"value": "CUSTOMPAY"
},
"Status": {
"value": "Pre-Authorized"
},
"custom": {}
}
],
"RequestedOn": {
"value": "2021-06-02T13:42:02.22Z"
},
"ShipToAddress": {
"AddressLine1": {},
"AddressLine2": {},
"City": {},
"Country": {},
"PostalCode": {},
"State": {},
"custom": {}
},
"ShipToAddressOverride": {
"value": false
},
"ShipToContact": {
"Attention": {},
"BusinessName": {},
"Email": {},
"Phone1": {},
"custom": {}
},
"ShipVia": {
"value": ""
},
"Status": {},
"TaxTotal": {
"value": 0
},
"Totals": {
"FreightCost": {
"value": 0
},
"DiscountTotal": {
"value": 0
},
"LineTotalAmount": {
"value": 79.99
},
"custom": {}
},
"custom": {
"Document": {
"AttributeAMT": {
"value": "79.99",
"type": "CustomStringField"
},
"AttributeAUTHID": {
"value": "23456",
"type": "CustomStringField"
},
"AttributeCUR": {
"value": "USD",
"type": "CustomStringField"
},
"AttributeDT": {
"value": "6/2/2021 4:13:01 PM",
"type": "CustomStringField"
},
"AttributeEXPDATE": {
"value": "2025-05",
"type": "CustomStringField"
},
"AttributeRC": {
"value": "0",
"type": "CustomStringField"
},
"AttributeTOKEN": {
"value": "Gmg9niiBqh8B8FXH",
"type": "CustomStringField"
},
"AttributeTRANID": {
"value": "12345",
"type": "CustomStringField"
},
"AttributeCID": {
"value": "B",
"type": "CustomStringField"
},
"AttributeSTATUS": {
"value": "Pending",
"type": "CustomStringField"
}
}
}
}
</code></pre>
public async Task Upsert(BusinessModel.Order
order)
{
// Map BusinessModel to DTO
var request = _mapper.Map(order);
//Add Payment record
DataModel.SalesOrderPayment payment = new
DataModel.SalesOrderPayment();
payment.Description = new StringValue { Value =
string.Format("Payment for {0}", order.OrderNumber)};
payment.PaymentMethod = new StringValue { Value =
"CUSTOMPAYMC" };
payment.CardAccountNbr = new StringValue { Value =
string.Concat(order.PaymentDetails.CardID) };
payment.CashAccount = new StringValue { Value = "10600" };
payment.ProcessingCenterID = new StringValue { Value =
"CUSTOMPAY"};
payment.Hold = new BooleanValue { Value = false };
payment.PaymentAmount = new DecimalValue { Value =
order.Header.TotalAmount };
payment.AppliedToOrder = new DecimalValue { Value =
order.Header.TotalAmount };
payment.Custom = new Dictionary>();
payment.Status = new StringValue { Value = "Pre-Authorized"
};
DataModel.SalesOrderCreditCardTransactionDetail detail = new
DataModel.SalesOrderCreditCardTransactionDetail();
detail.AuthNbr = new StringValue { Value =
order.PaymentDetails.AuthorizationNumber };
detail.NeedValidation = new BooleanValue { Value = false };
detail.TranDate = new DateTimeValue { Value =
order.PaymentDetails.AuthorizationDateTime };
detail.TranNbr = new StringValue { Value =
order.PaymentDetails.TransactionID };
detail.TranType = new StringValue { Value = "Authorize Only"
};
detail.Custom = new Dictionary>();
payment.CreditCardTransactionInfo = new
List();
//payment.CreditCardTransactionInfo.Add(detail);
request.Payments = new List();
request.Payments.Add(payment);
// Invoke API
SalesOrder salesOrderResponse = await
api.PutEntityAsync(request, null, null, null, null));
// Map response DTO to BusinessModel
var response = _mapper.Map
(salesOrderResponse);
return Ok(response);
}

Dialogflow textToSpeech fulfilment not reading aloud the text

I am providing users with a response on an audio only device (e.g. google home), when I respond with a textToSpeech field within a simpleResponse, the speech is not read out in the simulator.
Has anyone experienced this and know how to fix?
I've tried different response types but none of them read out the textToSpeech field.
Also tried ticking/unticking end conversation toggle in Dialogflow and expectUserInput true/false when responding with JSON to no avail.
The response is currently fulfilled by a webhook which responds with JSON v2 fulfilment blob and the simulator receives the response with no errors but does not read it out.
RESPONSE -
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Here are the 3 closest restaurants that match your criteria,"
}
}
]
}
}
}
}
REQUEST -
{
"responseId": "404f3b65-73a5-47db-9c17-0fc8b31560a5",
"queryResult": {
"queryText": "actions_intent_NEW_SURFACE",
"parameters": {},
"allRequiredParamsPresent": true,
"outputContexts": [
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/findrestaurantswithcuisineandlocation-followup",
"lifespanCount": 98,
"parameters": {
"location.original": "Shoreditch",
"cuisine.original": "international",
"cuisine": "International",
"location": {
"subadmin-area": "Shoreditch",
"subadmin-area.original": "Shoreditch",
"subadmin-area.object": {}
}
}
},
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/actions_capability_account_linking"
},
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/actions_capability_audio_output"
},
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/google_assistant_input_type_voice"
},
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/actions_capability_media_response_audio"
},
{
"name": "projects/my-project/agent/sessions/sessionId/contexts/actions_intent_new_surface",
"parameters": {
"text": "no",
"NEW_SURFACE": {
"#type": "type.googleapis.com/google.actions.v2.NewSurfaceValue",
"status": "CANCELLED"
}
}
}
],
"intent": {
"name": "projects/my-project/agent/intents/0baefc9d-689c-4c33-b2b8-4e130f626de1",
"displayName": "Send restaurants to mobile"
},
"intentDetectionConfidence": 1,
"languageCode": "en-us"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.ACCOUNT_LINKING"
}
]
},
"requestType": "SIMULATOR",
"inputs": [
{
"rawInputs": [
{
"query": "no",
"inputType": "VOICE"
}
],
"arguments": [
{
"extension": {
"#type": "type.googleapis.com/google.actions.v2.NewSurfaceValue",
"status": "CANCELLED"
},
"name": "NEW_SURFACE"
},
{
"rawText": "no",
"textValue": "no",
"name": "text"
}
],
"intent": "actions.intent.NEW_SURFACE"
}
],
"user": {
"userStorage": "{\"data\":{}}",
"lastSeen": "2019-04-12T14:31:23Z",
"locale": "en-US",
"userId": "userID"
},
"conversation": {
"conversationId": "sessionId",
"type": "ACTIVE",
"conversationToken": "[\"defaultwelcomeintent-followup\",\"findrestaurantswithcuisineandlocation-followup\",\"findrestaurantswithcuisineandlocation-followup-2\"]"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
}
]
}
},
"session": "projects/my-project/agent/sessions/sessionId"
}
I expect the simulator to read out the result of textToSpeech but currently does not.

Unable to parse list of Json blocks in U-SQL

I have a file with list of json blocks and am stuck with processing/Reading them in U-Sql and writing to a text file.
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
{
"id": "0002",
"type": "nut",
"name": "ake",
"ppu": 1.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
{
"id": "0003",
"type": "test",
"name": "ake",
"ppu": 1.55,
"batters":
{
"batter":
[
]
},
"topping":
[
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}
can someone help me on this.
REFERENCE ASSEMBLY [Newtonsoft.Json];
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];
DECLARE #Full_Path string = #"C:\Users\test\Desktop\File\JsonTest.json";
USING [Microsoft.Analytics.Samples.Formats];
#RawExtract =
EXTRACT
[RawString] string
FROM
#Full_Path
USING
Extractors.Text(delimiter:'\n', quoting : false);
#ParsedJSONLines =
SELECT JsonFunctions.JsonTuple([RawString]) AS JSONLine
FROM #RawExtract;
#StagedData =
SELECT
JSONLine["id"] AS Id,
JSONLine["name"] AS Name,
JSONLine["type"] AS Type,
JSONLine["ppu"] AS PPU,
JSONLine["batters"] AS Batter
FROM
#ParsedJSONLines;
DECLARE #Output_Path string = #"C:\Users\Test\Desktop\File\Test2.csv";
OUTPUT #StagedData
TO #Output_Path
USING Outputters.Csv();
Am receiving error while evaluating expression .
Error while evaluating expression JsonFunctions.JsonTuple(RawString)
You cant use an Text Extraxtor to extract Json, unless you use Json Lines.
Using the extractor will split the json and you will get the error.
Use JsonExtractor instead of Text extractor.
https://github.com/Azure/usql/blob/master/Examples/DataFormats/Microsoft.Analytics.Samples.Formats/Json/JsonExtractor.cs

Resources