SABRE Hotel Book request is missing TravelItineraryRead in the response - sabre

I'm having an issue performing the following SABRe hotel book in the CRT environment using an orchestrated workflow.
{
"CreatePassengerNameRecordRQ": {
"version": "2.3.0",
"TravelItineraryAddInfo": {
"CustomerInfo": {
"ContactNumbers": {
"ContactNumber": [
{
"NameNumber": "1.1",
"Phone": "17805555555",
"PhoneUseType": "H"
}
]
},
"Email": [
{
"Address": "chris#test.com",
"Type": "TO"
}
],
"PersonName": [
{
"NameNumber": "1.1",
"PassengerType": "ADT",
"GivenName": "Chris",
"Surname": "test"
}
]
}
},
"HotelBook": {
"BookingInfo": {
"BookingKey": "5d07cdba-0123-4510-9f9a-5257973b5f98",
"RequestorID": "SG000000"
},
"Rooms": {
"Room": [
{
"Guests": {
"Guest": [
{
...
}
]
},
"RoomIndex": 1
}
]
},
"PaymentInformation": {
"FormOfPayment": {
"PaymentCard": {
"PaymentType": "CC",
"CardCode": "VI",
"CardNumber": "4111111111111111",
"ExpiryMonth": 3,
"ExpiryYear": "2024",
"FullCardHolderName": {
"FirstName": "Chris",
"LastName": "test",
"Email": "chris#test.com"
},
"CSC": "013",
"Address": {
...
},
"Phone": {
"PhoneNumber": "17805555555"
}
}
},
"Type": "GUARANTEE"
},
"POS": {
"Source": {
"RequestorID": {
"Type": 5,
"Id": "XXX",
"IdContext": "IATA"
},
"AgencyAddress": {
"AddressLine1": "1 Lincoln Blvd",
"CountryName": {
"Code": "US"
}
},
"AgencyName": "Flying Wings",
"ISOCountryCode": "US",
"PseudoCityCode": "1MNJ"
}
}
},
"PostProcessing": {
"EndTransaction": {
"Source": {
"ReceivedFrom": "Flying Wings Web"
},
"Email": {
"Ind": true
}
}
}
}
}
The response I get is:
{
"CreatePassengerNameRecordRS": {
"ApplicationResults": {
"status": "Complete",
"Success": [
{
"timeStamp": "2021-03-08T01:18:50.544-06:00"
}
]
},
"ItineraryRef": {
"ID": "VKIJSI"
}
},
"Links": [
]
}
So a successful booking however I am expecting a TravelItineraryRead returned in the response and am not getting one. Am I missing something in the request?
Thanks.

try redisplaing the newly created reservation.
"RedisplayReservation": {
"waitInterval": 100
}
that should include the itinerary in the response

Related

Gatling jsonpath, save value

I have a json response I want to obtain a value from looking like this:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "medication",
"resource": {
"resourceType": "Bundle",
"id": "cfa4fa3c-0e34-431c-ac0d-91653ebda972",
"meta": {
"lastUpdated": "2022-09-23T11:37:49.6022504+02:00",
"source": "http://xxx.xxx/Patient/$getMedication",
"profile": [
"http://xxxStructureDefinition/sfm-MedicationBundle"
]
},
"type": "document",
"timestamp": "2022-09-23T11:37:49.6022471+02:00",
"total": 6,
"link": [
{
"relation": "self",
"url": "http://xxx/Patient/$getMedication"
}
],
"entry": [
{
"fullUrl": "urn:uuid:fbb2bd18-a1c3-4f95-8384-d520fba283a5",
"resource": {
"resourceType": "Composition",
"id": "dfc4f003-4eb6-4802-8b8a-d2d53cf7698c",
"meta": {
"profile": [
"http://xxx/StructureDefinition/sfm-MedicationComposition"
]
},
"identifier": {
"use": "official",
"value": "28c2ae8d-39ed-4054-af46-22bc8c2c1e4a"
},
"status": "final",
"type": {
"coding": [
{
"system": "http://loinc.org",
"code": "11503-0",
"display": "Medical records"
}
]
},
"subject": {
"reference": "urn:uuid:67bb77c3-55dc-4643-b334-7f95e38bcf2f",
"type": "http://xxx/StructureDefinition/sfm-Patient",
"display": "Patient 05129997836"
},
"date": "2022-09-23",
"author": [
{
"reference": "urn:uuid:a443c8b2-a45a-4bad-baa6-f38904363673",
"type": "http://xxx/StructureDefinition/sfm-Practitioner",
"display": "xxx xxx, HPR: xxx"
}
],
"title": "Medication summary",
"confidentiality": "N",
"section": [
{
"title": "Medication",
"code": {
"coding": [
{
"system": "http://xxx/CodeSystem/sfm-section-types",
"code": "sectionMedication",
"display": "List of Medication statements"
}
]
},
"text": {
"status": "generated",
"div": "<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">List of medications</xhtml:div>"
},
"entry": [
{
"reference": "urn:uuid:8c714f72-0c90-403d-9e80-b08c61f82068",
"type": "http://xxx/fhir/StructureDefinition/sfm-MedicationStatement",
"display": "Paracetamol tab 1 g"
}
]
},
{
"title": "PllInfo",
"code": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-section-types",
"code": "sectionPLLinfo",
"display": "PLL Info"
}
]
},
"text": {
"status": "generated",
"div": "<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">Nil Known</xhtml:div>"
},
"emptyReason": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/list-empty-reason",
"code": "nilknown",
"display": "Nil Known"
}
],
"text": "Nil Known"
}
},
{
"title": "Allergies",
"code": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-section-types",
"code": "sectionAllergies",
"display": "Section allergies"
}
]
},
"text": {
"status": "generated",
"div": "<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">Nil Known</xhtml:div>"
},
"emptyReason": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/list-empty-reason",
"code": "nilknown",
"display": "Nil Known"
}
],
"text": "Nil Known"
}
},
{
"title": "Other Prescriptions",
"code": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-section-types",
"code": "sectionOtherPrescriptions",
"display": "List of non medical prescriptions"
}
]
},
"text": {
"status": "generated",
"div": "<xhtml:div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">Nil Known</xhtml:div>"
},
"emptyReason": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/list-empty-reason",
"code": "nilknown",
"display": "Nil Known"
}
],
"text": "Nil Known"
}
}
]
}
},
{
"fullUrl": "urn:uuid:a443c8b2-a45a-4bad-baa6-f38904363673",
"resource": {
"resourceType": "Practitioner",
"id": "1571880245",
"meta": {
"profile": [
"http://xxx/fhir/StructureDefinition/sfm-Practitioner"
]
},
"identifier": [
{
"use": "official",
"type": {
"coding": [
{
"system": "http://hl7.no/fhir/NamingSystem/HPR",
"code": "HPR-nummer"
}
]
},
"system": "urn:oid:2.16.578.1.12.4.1.4.4",
"value": "10055817"
},
{
"use": "official",
"type": {
"coding": [
{
"system": "http://hl7.no/fhir/NamingSystem/FNR",
"code": "FNR-nummer"
}
]
},
"system": "urn:oid:2.16.578.1.12.4.1.4.1",
"value": "10099205569"
}
],
"active": true,
"name": [
{
"use": "official",
"family": "xxx",
"given": [
"xxx"
]
}
],
"gender": "male",
"birthDate": "1992-09-10"
}
},
{
"fullUrl": "urn:uuid:67bb77c3-55dc-4643-b334-7f95e38bcf2f",
"resource": {
"resourceType": "Patient",
"id": "873788333",
"meta": {
"profile": [
"http://xxx/fhir/StructureDefinition/sfm-Patient"
]
},
"identifier": [
{
"use": "official",
"type": {
"coding": [
{
"system": "http://hl7.no/fhir/NamingSystem/FNR",
"code": "FNR-nummer"
}
]
},
"system": "urn:oid:2.16.578.1.12.4.1.4.1",
"value": "05129997836"
}
],
"active": true,
"name": [
{
"family": "05129997836",
"given": [
"Patient"
]
}
],
"gender": "female",
"birthDate": "1999-12-05",
"address": [
{
"type": "postal",
"text": "Autoveien 1",
"city": "Oslo",
"postalCode": "0150"
}
]
}
},
{
"fullUrl": "urn:uuid:f4c95e15-8e9f-416a-83c7-3a6847d69278",
"resource": {
"resourceType": "Practitioner",
"id": "1215535826",
"meta": {
"profile": [
"http://xxx/fhir/StructureDefinition/sfm-Practitioner"
]
},
"identifier": [
{
"use": "official",
"type": {
"coding": [
{
"system": "http://hl7.no/fhir/NamingSystem/HPR",
"code": "HPR-nummer"
}
]
},
"system": "urn:oid:2.16.578.1.12.4.1.4.4",
"value": "1010038"
}
],
"active": true,
"name": [
{
"extension": [
{
"url": "http://hl7.no/fhir/StructureDefinition/no-basis-middlename",
"valueString": "Psa"
}
],
"use": "official",
"family": "xx",
"given": [
"xx"
]
}
],
"gender": "male"
}
},
{
"fullUrl": "urn:uuid:4b4de0ae-3f2d-4030-a193-26713cf30260",
"resource": {
"resourceType": "Medication",
"id": "667718723",
"meta": {
"profile": [
"http://xxx/fhir/StructureDefinition/sfm-Medication"
]
},
"extension": [
{
"extension": [
{
"url": "prescriptiongroup",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.7421",
"code": "C",
"display": "Reseptgruppe C"
}
]
}
}
],
"url": "http://hl7.no/fhir/StructureDefinition/no-basis-prescriptiongroup"
},
{
"extension": [
{
"url": "registreringstype",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-festregistrationtype",
"code": "1",
"display": "Legemiddelvirkestoff"
}
]
}
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-medicationdetails"
}
],
"identifier": [
{
"use": "official",
"type": {
"text": "identifier"
},
"value": "ID_DF40453A-DAD1-450D-A58D-0FE411DCDB05"
}
],
"code": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/FEST",
"code": "ID_DF40453A-DAD1-450D-A58D-0FE411DCDB05",
"display": "Paracetamol tab 1 g"
},
{
"system": "http://www.whocc.no/atc",
"code": "N02BE01",
"display": "Paracetamol"
}
]
},
"status": "active",
"form": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.7448",
"code": "53",
"display": "Tablett"
}
]
}
}
},
{
"fullUrl": "urn:uuid:8c714f72-0c90-403d-9e80-b08c61f82068",
"resource": {
"resourceType": "MedicationStatement",
"id": "1850837775",
"meta": {
"profile": [
"http://xxx/fhir/StructureDefinition/sfm-MedicationStatement"
]
},
"extension": [
{
"extension": [
{
"url": "reseptdate",
"valueDate": "2022-09-21"
},
{
"url": "expirationdate",
"valueDate": "2023-09-20"
},
{
"url": "festUpdate",
"valueDateTime": "2022-08-25T13:54:02+00:00"
},
{
"url": "dssn",
"valueString": "1 tablett morgen daglig"
},
{
"url": "amount",
"valueQuantity": {
"value": 92.0,
"unit": "stk"
}
},
{
"url": "reit",
"valueString": "3"
},
{
"url": "itemgroup",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.7402",
"code": "L",
"display": "Legemiddel"
}
]
}
},
{
"extension": [
{
"url": "starttime",
"valueDate": "2022-09-21"
},
{
"extension": [
{
"url": "amount",
"valueQuantity": {
"value": 1.0,
"unit": "tablett"
}
},
{
"url": "interval",
"valueQuantity": {
"value": 1.0,
"unit": "Døgn"
}
},
{
"url": "accurate",
"valueBoolean": false
},
{
"url": "timerange",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.8325",
"code": "1",
"display": "Morgen"
}
]
}
}
],
"url": "repeatingdosage"
}
],
"url": "ereseptdosing"
},
{
"extension": [
{
"url": "status",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.7408",
"code": "E",
"display": "Ekspederbar"
}
]
}
}
],
"url": "rfstatus"
},
{
"url": "typeresept",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.7491",
"code": "E",
"display": "Eresept"
}
]
}
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-reseptamendment"
},
{
"extension": [
{
"url": "status",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-medicationstatement-registration-status",
"code": "3",
"display": "Godkjent"
}
]
}
},
{
"url": "type",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-performer-roles",
"code": "1",
"display": "Forskrevet av"
}
]
}
},
{
"url": "provider",
"valueReference": {
"reference": "urn:uuid:f4c95e15-8e9f-416a-83c7-3a6847d69278",
"type": "http://xxx/fhir/StructureDefinition/sfm-Practitioner",
"display": "Bjørn Psa Visjon, HPR: 1010038"
}
},
{
"url": "timestamp",
"valueDateTime": "2022-09-21T16:10:25.5229768+02:00"
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-regInfo"
},
{
"extension": [
{
"url": "genericSubstitutionAccepted",
"valueBoolean": true
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-generic-substitution"
},
{
"extension": [
{
"url": "nocombination",
"valueBoolean": false
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-administration"
}
],
"identifier": [
{
"use": "usual",
"type": {
"text": "ReseptId"
},
"value": "1dfa55d7-674d-4fc8-a182-1fbd3b2faa6a"
}
],
"status": "active",
"medicationReference": {
"reference": "urn:uuid:4b4de0ae-3f2d-4030-a193-26713cf30260",
"type": "http://xxx/fhir/StructureDefinition/sfm-Medication",
"display": "Paracetamol tab 1 g"
},
"subject": {
"reference": "urn:uuid:67bb77c3-55dc-4643-b334-7f95e38bcf2f",
"type": "http://xxx/fhir/StructureDefinition/sfm-Patient",
"display": "Patient 05129997836"
},
"dosage": [
{
"extension": [
{
"url": "http://xxx/fhir/StructureDefinition/sfm-use",
"valueCodeableConcept": {
"coding": [
{
"system": "urn:oid:2.16.578.1.12.4.1.1.9101",
"code": "1",
"display": "Fast"
}
]
}
},
{
"extension": [
{
"url": "text",
"valueString": "MOT SMERTER"
}
],
"url": "http://xxx/fhir/StructureDefinition/sfm-application-area"
}
],
"sequence": 1,
"text": "1 tablett morgen daglig"
}
]
}
}
]
}
},
{
"name": "KJHentetTidspunkt",
"valueDateTime": "2022-09-23T09:37:49.55+00:00"
},
{
"name": "RFHentetTidspunkt",
"valueDateTime": "2022-09-23T11:37:49.027+02:00"
},
{
"name": "KJFeilkode",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-kj-rf-error-code",
"code": "0"
}
],
"text": "OK"
}
},
{
"name": "RFM96Feilkode",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-kj-rf-error-code",
"code": "0"
}
],
"text": "OK"
}
},
{
"name": "RFM912Feilkode",
"valueCodeableConcept": {
"coding": [
{
"system": "http://xxx/fhir/CodeSystem/sfm-kj-rf-error-code",
"code": "0"
}
],
"text": "OK"
}
},
{
"name": "KJHarLegemidler",
"valueBoolean": false
},
{
"name": "KJHarLaste",
"valueBoolean": false
},
{
"name": "RFHarLaste",
"valueBoolean": false
}
]
}
The value I am looking for is the "fullUrl", as in urn:uuid:fbb2bd18-a1c3-4f95-8384-d520fba283a5
I tried to use this jsonpath expression:
.check(jsonPath("$..[?(#.resourceType=="Bundle")].entry.fullUrl").saveAs("fullUrl"))
However it says
jsonPath($..[?(#.resourceType=="Bundle")].entry.fullUrl).find. exists, found nothing
How can I construct an experssion to obtain the fullUrl?
It's because entry is array. So you have two options how to extract the value.
You can get all fullUrl values and then obtain via Gatling EL:
jsonPath("$..[?(#.resourceType=='Bundle')].entry..fullUrl").findAll.saveAs("fullUrls")
And then just get by index #{fullUrls(0)} (Documentation)
Or get by index in the json path:
|
|
ᐯ
jsonPath("$..[?(#.resourceType=='Bundle')].entry.[0].fullUrl").findAll.saveAs("fullUrl")

Can I get the user email within a Velocity template of AWS Amplify?

When I query a resolver in my GraphQL API, in which I have added a $util.error($ctx) to return the context object, I get the following result (removed unnecessary values).
{
"data": {
"listXData": null
},
"errors": [
{
"message": {
"arguments": {},
"args": {},
"info": {
"fieldName": "listXData",
"variables": {},
"parentTypeName": "Query",
"selectionSetList": [
"items",
"items/id",
"items/createdAt",
"items/updatedAt",
"nextToken"
],
"selectionSetGraphQL": "{\n items {\n id\n createdAt\n updatedAt\n }\n nextToken\n}"
},
"request": {...},
"identity": {
"sub": "",
"issuer": "",
"username": "013fe9d2-95f7-4885-83ec-b7e2e0a1423f",
"sourceIp": "",
"claims": {
"origin_jti": "",
"sub": "",
"event_id": "",
"token_use": "",
"scope": "",
"auth_time": ,
"iss": "",
"exp": ,
"iat": ,
"jti": "",
"client_id": "",
"username": "013fe9d2-95f7-4885-83ec-b7e2e0a1423f"
},
"defaultAuthStrategy": "ALLOW"
},
"stash": {},
"source": null,
"result": {
"items": [],
"scannedCount": 0,
"nextToken": null
},
"error": null,
"prev": {
"result": {}
}
},
"errorType": null,
"data": null,
"errorInfo": null,
"path": [
"listXData"
],
"locations": [
{
"line": 2,
"column": 3,
"sourceName": "GraphQL request"
}
]
}
]
}
As you can see, the username is an ID, however I would prefer to (also) have the email. Is it possible to get the user email (within the Velocity template)?
Let me know if I need to add more details or if my question is unclear.
The identity context only returns back the Cognito username for the user pool. You will need to setup pipeline functions to perform additional queries to get your user information. Here is one intro to setting them up.
At this point, it seems that it is not possible to do this purely by vtl.
I have implemented it using a lambda function, as follow:
Lambda function (node):
/* Amplify Params - DO NOT EDIT
ENV
REGION
Amplify Params - DO NOT EDIT */
const aws = require('aws-sdk')
const cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({
apiVersion: '2016-04-18',
region: 'eu-west-1'
})
exports.handler = async (context, event, callback) => {
if (!context.identity?.username) {
callback('Not signed in')
}
const params = {
'AccessToken': context.request.headers.authorization
}
const result = await cognitoidentityserviceprovider.getUser(params).promise()
const email = result.UserAttributes.find(attribute => attribute.Name === 'email')
callback(null, JSON.stringify({ email }))
}
CustomResources.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "An auto-generated nested stack.",
"Metadata": {...},
"Parameters": {...},
"Resources": {
"GetEmailLambdaDataSourceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": {
"Fn::If": [
"HasEnvironmentParameter",
{
"Fn::Join": [
"-",
[
"GetEmail17ec",
{
"Ref": "GetAttGraphQLAPIApiId"
},
{
"Ref": "env"
}
]
]
},
{
"Fn::Join": [
"-",
[
"GetEmail17ec",
{
"Ref": "GetAttGraphQLAPIApiId"
}
]
]
}
]
},
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "appsync.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Policies": [
{
"PolicyName": "InvokeLambdaFunction",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": {
"Fn::If": [
"HasEnvironmentParameter",
{
"Fn::Sub": [
"arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:GetEmail-${env}",
{
"env": {
"Ref": "env"
}
}
]
},
{
"Fn::Sub": [
"arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:GetEmail",
{}
]
}
]
}
}
]
}
}
]
}
},
"GetEmailLambdaDataSource": {
"Type": "AWS::AppSync::DataSource",
"Properties": {
"ApiId": {
"Ref": "AppSyncApiId"
},
"Name": "GetEmailLambdaDataSource",
"Type": "AWS_LAMBDA",
"ServiceRoleArn": {
"Fn::GetAtt": [
"GetEmailLambdaDataSourceRole",
"Arn"
]
},
"LambdaConfig": {
"LambdaFunctionArn": {
"Fn::If": [
"HasEnvironmentParameter",
{
"Fn::Sub": [
"arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:GetEmail-${env}",
{
"env": {
"Ref": "env"
}
}
]
},
{
"Fn::Sub": [
"arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:GetEmail",
{}
]
}
]
}
}
},
"DependsOn": "GetEmailLambdaDataSourceRole"
},
"InvokeGetEmailLambdaDataSource": {
"Type": "AWS::AppSync::FunctionConfiguration",
"Properties": {
"ApiId": {
"Ref": "AppSyncApiId"
},
"Name": "InvokeGetEmailLambdaDataSource",
"DataSourceName": "GetEmailLambdaDataSource",
"FunctionVersion": "2018-05-29",
"RequestMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/pipelineFunctions/${ResolverFileName}",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
},
"ResolverFileName": {
"Fn::Join": [
".",
[
"InvokeGetEmailLambdaDataSource",
"req",
"vtl"
]
]
}
}
]
},
"ResponseMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/pipelineFunctions/${ResolverFileName}",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
},
"ResolverFileName": {
"Fn::Join": [
".",
[
"InvokeGetEmailLambdaDataSource",
"res",
"vtl"
]
]
}
}
]
}
},
"DependsOn": "GetEmailLambdaDataSource"
},
"IsOrganizationMember": {
"Type": "AWS::AppSync::FunctionConfiguration",
"Properties": {
"FunctionVersion": "2018-05-29",
"ApiId": {
"Ref": "AppSyncApiId"
},
"Name": "IsOrganizationMember",
"DataSourceName": "PermissionsPerOrganizationTable",
"RequestMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.isOrganizationMember.req.vtl",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
}
}
]
},
"ResponseMappingTemplateS3Location": {
"Fn::Sub": [
"s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/resolvers/Query.isOrganizationMember.res.vtl",
{
"S3DeploymentBucket": {
"Ref": "S3DeploymentBucket"
},
"S3DeploymentRootKey": {
"Ref": "S3DeploymentRootKey"
}
}
]
}
}
},
"OrganizationAccessPipeline": {
"Type": "AWS::AppSync::Resolver",
"Properties": {
"ApiId": {
"Ref": "AppSyncApiId"
},
"TypeName": "Query",
"Kind": "PIPELINE",
"FieldName": "listXData",
"PipelineConfig": {
"Functions": [
{
"Fn::GetAtt": [
"InvokeGetEmailLambdaDataSource",
"FunctionId"
]
},
{
"Fn::GetAtt": [
"IsOrganizationMember",
"FunctionId"
]
}
]
},
"RequestMappingTemplate": "{}",
"ResponseMappingTemplate": "$util.toJson($ctx.result)"
}
}
},
"Conditions": {...},
"Outputs": {...}
}
The lambda is created with the CLI and IsOrganizationMember is a regular VTL which has the user email in the $context.prev.result.

AWS Stepfunctions dynamodb States.Runtime catch fails

My Stepfunction is supposed to check whether an item exist in the dynamo. if it does, it needs to generate the presigned url, otherwise it has to update the dynamodb item.
When it matches the item, it works as expected where as it fails when dynamo getitem output is null fails with states.runtime error. It does not going through catch statement. appreciate any help.
Here is my code.
{ "Comment": "A Hello World example of the Amazon States Language using Pass states", "StartAt": "Hello", "States": {
"Hello": {
"Type": "Pass",
"Next": "Verify item from DynamoDB"
},
"s3_url": {
"Type": "Pass",
"Result": "Hello",
"End": true
},
"Verify item from DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "s3_table",
"Key": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
}
}
},
"ResultPath": "$.DynamoDB",
"OutputPath": "$.DynamoDB.Item",
"Next": "s3_url",
"Catch": [
{
"ErrorEquals": [
"States.Runtime"
],
"Next": "DynamoDB Update"
}
]
},
"DynamoDB Update": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "s3_table",
"Item": {
"etag": {
"S.$": "$.eTag"
},
"filekey": {
"S": "mp3Files"
}
}
},
"End": true
} } }
solved this using choice state. Open to hear any suggestions on Catch state.
Here is the code.
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "Pass",
"Next": "Verify item from DynamoDB"
},
"s3_url": {
"Type": "Pass",
"Result": "Hello",
"End": true
},
"Verify item from DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "s3_table",
"Key": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
}
}
},
"ResultPath": "$.Records[0].DynamoDB",
"OutputPath": "$",
"Next": "Choice State",
"Catch": [
{
"ErrorEquals": [
"States.Runtime"
],
"Next": "DynamoDB Update"
}
]
},
"Choice State": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Records[0].DynamoDB.Item.etag.S",
"IsPresent": true,
"Next": "s3_url"
}
],
"Default": "DynamoDB Update"
},
"DynamoDB Update": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "s3_table",
"Item": {
"etag": {
"S.$": "$.Records[0].s3.object.eTag"
},
"filekey": {
"S.$": "$.Records[0].s3.object.key"
}
}
},
"End": true
}
}
}

Actions-on-Google can not get UPDATES_USER_ID on Dialogflow SDK

I'm setting up an action which uses push notifications. Yet, on firebase I can't get "UPDATES_USER_ID" of user to save. It returns "undefined".
I followed the guide on this link and here is my code to get UPDATES_USER_ID.
app.intent('Setup', (conv, params) => {
conv.ask(new UpdatePermission({
intent: "notificationResponseIntent"
}));
});
app.intent("FinishNotificationSetup", (conv, params) => {
if (conv.arguments.get('PERMISSION')) {
conv.data.GoogleUserID = conv.arguments.get("UPDATES_USER_ID");
console.log(conv.data.GoogleUserID);
conv.ask("some response....");
}
});
And here is my webhook request when FinishNotificationSetup intent is invoked.
{
"responseId": "2f425fe5-db42-47dc-90a1-c9bc85f725d2",
"queryResult": {
"queryText": "actions_intent_PERMISSION",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentMessages": [
{
"text": {
"text": [
""
]
}
}
],
"outputContexts": [
{
"name": "projects/projectname/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_screen_output"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_intent_permission",
"parameters": {
"PERMISSION": true,
"text": ""
}
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/_actions_on_google",
"lifespanCount": 98,
"parameters": {
"data": "{\"***":\"***",\"***":\"***"}"
}
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_account_linking"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_audio_output"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/google_assistant_input_type_keyboard"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_web_browser"
},
{
"name": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA/contexts/actions_capability_media_response_audio"
}
],
"intent": {
"name": "projects/projectname-10c22/agent/intents/a12b6d3f-0f24-45e9-a1b2-5649083831b0",
"displayName": "FinishNotificationSetup"
},
"intentDetectionConfidence": 1,
"languageCode": "tr"
},
"originalDetectIntentRequest": {
"source": "google",
"version": "2",
"payload": {
"isInSandbox": true,
"surface": {
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.ACCOUNT_LINKING"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"requestType": "SIMULATOR",
"inputs": [
{
"rawInputs": [
{
"inputType": "KEYBOARD"
}
],
"arguments": [
{
"textValue": "true",
"name": "PERMISSION",
"boolValue": true
},
{
"name": "text"
}
],
"intent": "actions.intent.PERMISSION"
}
],
"user": {
"lastSeen": "2019-04-30T07:23:23Z",
"permissions": [
"UPDATE"
],
"locale": "tr-TR",
"userId": "ABwppHHCEdtf23ZaNg0DaCv3fvshSUXUvYGXHe6kR7jbKacwIS6vDBBL7YXbN70jYa8KaXWZqbsyhFFSdsYLiw"
},
"conversation": {
"conversationId": "ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA",
"type": "ACTIVE",
"conversationToken": "[\"_actions_on_google\"]"
},
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
}
]
}
},
"session": "projects/projectname-10c22/agent/sessions/ABwppHGD33Tyho41g9Mr2vzxePlskNmvOzCTxUiDGzENcl3C7RQs94aOQ8ae_DUlOApR0VBO9DuwAWdWr2frAA"
}
To send notification, I've been using userID instead of UPDATES_USER_ID and it is working. Yet, it will be deprecated soon. So, I need to find a solution to get this ID and couldn't make it working. What do I need to do to get this ID?
I've found solution for this problem. While getting UPDATES_USER_ID conv.arguments.get() only works for first attempt. So, while building your action you must save it. If you didn't store or save, you can reset your profile and try again, you will be able to get.
app.intent("FinishNotificationSetup", (conv, params) => {
if (conv.arguments.get('PERMISSION')) {
if(!conv.user.storage.GoogleUserID)
{
conv.user.storage.GoogleUserID = conv.arguments.get("UPDATES_USER_ID");
//For best case
//store ID in your db.
}
console.log(conv.user.storage.GoogleUserID);
conv.ask("some response....");
}
});
For best case, try saving this to your database because conv.user.storage does not work sometimes.

Deploying a logic app using ARM templates/powershell

How can I Deploy a logic app that calls a SQL DB stored procedure? I've tried the following action.
"actions": {
"Execute_stored_procedure": {
"conditions": [ ],
"inputs": {
"body": null,
"host": {
"api": {
"runtimeUrl": "https://logic-apis-northcentralus.azure-apim.net/apim/sql"
},
"connection": {
"name": "<sql connection string>"
}
},
"method": "post",
"path": "/datasets/default/procedures/#{encodeURIComponent(encodeURIComponent(string('<stored-procedure-name>')))}"
},
"type": "apiconnection"
}
}
When I deploy this template, the logic app get's created but it's throwing errors or the SQL Connection action is not showing up on the design view. What am I doing wrong here? Is Logic App for calling SQL Stored Proc supported by arm currently?
Here is a sample template for LogicApp ARM template + 'connections' resource
https://blogs.msdn.microsoft.com/logicapps/2016/02/23/deploying-in-the-logic-apps-preview-refresh/
https://github.com/jeffhollan/logicapps-deployments/blob/master/ftp_to_blob.json
I've finally figured this out from #TusharJ links and I'm posting the template I've used below to configure a LogicApp that calls a SQL DB stored procedure in specific intervals.
resources:
[
{
"type": "Microsoft.Web/connections",
"apiVersion": "2015-08-01-preview",
"location": "[resourceGroup().location]",
"name": "sqlconnector",
"properties": {
"api": {
"id": "[concat('subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
},
"displayName": "sqlconnector",
"parameterValues": {
"sqlConnectionString": "<sql db connection string>"
}
}
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2015-08-01-preview",
"name": "[parameters('logicAppName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "LogicApp"
},
"properties": {
"sku": {
"name": "[parameters('workflowSkuName')]",
"plan": {
"id": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('svcPlanName'))]"
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2015-08-01-preview/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": { },
"type": "Object"
}
},
"triggers": {
"recurrence": {
"type": "recurrence",
"recurrence": {
"frequency": "Hour",
"interval": 1
}
}
},
"actions": {
"Execute_stored_procedure": {
"conditions": [ ],
"inputs": {
"body": null,
"host": {
"api": {
"runtimeUrl": "[concat('https://logic-apis-', resourceGroup().location, '.azure-apim.net/apim/sql')]"
},
"connection": {
"name": "#parameters('$connections')['sql']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/procedures/#{encodeURIComponent(encodeURIComponent(string('[dbo].[<Stored Proc Name>]')))}"
},
"type": "apiconnection"
}
},
"outputs": { }
},
"parameters": {
"$connections": {
"value": {
"sql": {
"connectionId": "[resourceId('Microsoft.Web/connections', 'sqlconnector')]",
"connectionName": "sqlconnector",
"id": "[reference(concat('Microsoft.Web/connections/', 'sqlconnector'), '2015-08-01-preview').api.id]"
}
}
}
}
}
}
]
Things may have changed in the API since the previous answer was given. Here is what worked for me as of 10/2016. Note: I used parameters (definitions not shown) for many of the variables:
{
"type": "Microsoft.Web/connections",
"apiVersion": "2015-08-01-preview",
"location": "[parameters('location')]",
"name": "[variables('sql_conn_name')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
},
"displayName": "sql_connection",
"parameterValues": {
"server": "[concat(variables('dbserver_unique_name'), '.database.windows.net')]",
"database": "[parameters('databases_name')]",
"authType": "windows",
"username": "[parameters('databases_admin_user')]",
"password": "[parameters('databases_admin_password')]"
}
}
},
{
"type": "Microsoft.Logic/workflows",
"name": "[variables('logic_app_name')]",
"apiVersion": "2016-06-01",
"location": "[parameters('location')]",
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": { },
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Hour",
"interval": 1
},
"type": "Recurrence"
}
},
"actions": {
"Execute_stored_procedure": {
"runAfter": { },
"type": "ApiConnection",
"inputs": {
"body": {
"timeoffset": "-4"
},
"host": {
"api": {
"runtimeUrl": "[concat('https://logic-apis-', parameters('location'), '.azure-apim.net/apim/sql')]"
},
"connection": {
"name": "#parameters('$connections')['sql']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/procedures/#{encodeURIComponent(encodeURIComponent('[dbo].[usp_UpdateHourlyOos]'))}"
}
}
},
"outputs": { }
},
"parameters": {
"$connections": {
"value": {
"sql": {
"connectionId": "[concat(subscription().id, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Web/connections/', variables('sql_conn_name'))]",
"connectionName": "[variables('sql_conn_name')]",
"id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
}
}
}
}
},
"resources": [ ],
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('sql_conn_name'))]"
]
}

Resources