First of all, I tried to write how to save users input data to google sheet after developing the simple codes. It's able to work. Thank Mr.Master for providing this tutorial(Below the link).
Reference Mr.Master: https://www.youtube.com/watch?v=huwUpJZsTok
Next, I bumped into the problem below the code. I didn't know how to write it in Fulfillment. Could someone realize it to teach me?
Tool: Dialogflow, Google sheet, Firebase.
Theme: Order process
I tried to write Forhere() there. However, it didn't work.(First code)
function Forhere(agent){
const{
forhere, howmanypeople, whattime, namelist
} = agent.parameters;
const data1 = [{
Forhere: forhere,
HowManyPeople: howmanypeople,
Time: whattime,
Name: namelist
}];
axios.post('......', data1);
}
{/*....This code is a result of test(second one)
"responseId": "d0f44937-e58a-4b71-b6dc-ec2d6c39337b-f308a5c4",
"queryResult": {
"queryText": "黃大哥",
"parameters": {
"forhere": [
"內用"
],
"howmanypeople": [
2
],
"whattime": [
**{
"date_time": "2019-09-19T14:00:00+08:00"
}**
],
"namelist": [
"黃大哥"
]
},
"allRequiredParamsPresent": true,
"outputContexts": [
{
"name": "projects/test-tyrpxs/agent/sessions/5dd26d5c-bd99-072c-3693-41f95a3a348d/contexts/forhere",
"lifespanCount": 4,
"parameters": {
"howmanypeople": [
2
],
"namelist.original": [
"黃大哥"
],
"howmanypeople.original": [
"2"
],
"forhere": [
"內用"
],
"whattime.original": [
"明天下午2點"
],
"welcome": "嗨",
"whattime": [
{
"date_time": "2019-09-19T14:00:00+08:00"
}
],
"namelist": [
"黃大哥"
],
"welcome.original": "hi",
"forhere.original": [
"內用"
]
}
}
],
"intent": {
"name": "projects/test-tyrpxs/agent/intents/ec0f55c4-e9c9-401f-bce7-d2478c40fb85",
"displayName": "ForHere"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 4992
},
"languageCode": "zh-tw"
},
"webhookStatus": {
"code": 4,
"message": "Webhook call failed. Error: Request timeout."
}
}
You can use below code
let forhere= agent.parameters.forhere;
let howmanypeople= agent.parameters.howmanypeople;
let whattime= agent.parameters.whattime;
let namelist= agent.parameters.namelist;
then use this variables in your api call.
To T.Ali:
Dialogflowfirebasefulfillment&Error message:
Although I think this error didn't show where these mistakes are.
Dialogflow Request body: {"responseId":"ab277bc6-3bcc-4c4b-9a94-192b9ecfb8af-f308a5c4","queryResult":{"queryText":"黃大哥","parameters":{"forhere":"內用","whattime":{"date_time":"2019-09-20T12:00:00+08:00"},"howmanypeople":3,"namelist":"黃大哥"},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/test-tyrpxs/agent/sessions/5dd26d5c-bd99-072c-3693-41f95a3a348d/contexts/forhere","lifespanCount":4,"parameters":{"welcome":"嗨","welcome.original":"hi","forhere":"內用","forhere.original":"內用","whattime":{"date_time":"2019-09-20T12:00:00+08:00"},"whattime.original":"明天中午","howmanypeople":3,"howmanypeople.original":"3","namelist":"黃大哥","namelist.original":"黃大哥"}}],"intent":{"name":"projects/test-tyrpxs/agent/intents/ec0f55c4-e9c9-401f-bce7-d2478c40fb85","displayName":"ForHere"},"intentDetectionConfidence":1,"languageCode":"zh-tw"},"originalDetectIntentRequest":{"payload":{}},"session":"projects/test-tyrpxs/agent/sessions/5dd26d5c-bd99-072c-3693-41f95a3a348d"}
Error: No handler for requested intent
at WebhookClient.handleRequest (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:317:29)
at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/srv/index.js:105:9)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:57:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
Furthermore, I've write below the code worked formally(input users data to google sheet).
enter image description here
Related
I've been working on an issue and seem to be stuck, so asking on so in case anyone can help.
To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. It needs to be conditional as if the function name is "false" then that function should not be added to key vault access policy.
variable section:
"variables": {
"functionAccess": {
"value": [
{
"name": "[parameters('Function_1')]"
},
{
"name": "[parameters('Function_2')]"
},
{
"name": "[parameters('Function_3')]"
}
]
}
}
My Template :
{
"apiVersion": "2016-10-01",
"condition": "[not(equals(variables('functionAccess')[CopyIndex()].name, 'false'))]",
"copy": {
"batchSize": 1,
"count": "[length(variables('functionAccess'))]",
"mode": "Serial",
"name": "accessPolicies"
},
"name": "[concat(parameters('KeyVault_Name'), '/add')]",
"properties": {
"accessPolicies": [
{
"tenantId": "[subscription().tenantId]",
"objectId": "[if(not(equals(variables('functionAccess')[CopyIndex()].name, 'false')), reference(concat('Microsoft.Web/sites/', variables('functionAccess')[CopyIndex()].name), '2016-08-01', 'Full').identity.principalId, json('null'))]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
},
"type": "Microsoft.KeyVault/vaults/accessPolicies"
}
When I deploy my ARM template for the azure key vault I got this error message:
The language expression property '0' can't be evaluated, property name must be a string.
also tried below, but same error:
{
"apiVersion": "2018-02-14",
"name": "[concat(parameters('KeyVault_Name'), '/add')]",
"properties": {
"copy": [
{
"batchSize": 1,
"count": "[length(variables('functionAccess'))]",
"mode": "serial",
"name": "accessPolicies",
"input": {
"condition": "[not(equals(variables('functionAccess')[copyIndex('accessPolicies')].name, 'false'))]",
"tenantId": "[subscription().tenantId]",
"objectId": "[if(not(equals(variables('functionAccess')[copyIndex('accessPolicies')].name, 'false')), reference(concat('Microsoft.Web/sites/', variables('functionAccess')[copyIndex('accessPolicies')].name), '2016-08-01', 'Full').identity.principalId, json('null'))]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
}
]
},
"type": "Microsoft.KeyVault/vaults/accessPolicies"
}
There are a few options for dealing with filtering an array for copy operation. I deploy my ARM templates from PowerShell scripts and use PowerShell to setup parameter values. When I need special logic handle different inputs for different environments, I let PowerShell handle it.
If you must handle the filtering in ARM and you have the option to input a CSV list of functions, then perhaps the following will work. You can then use the functionAccessArray to iterate over in the copy operation.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
"functionAccessCsv": "Function-0,Function-1,false,Function-4,false,Function-6,Function-7",
"functionAccessFiltered": "[replace(replace(variables('functionAccessCsv'), 'false', ''), ',,', ',')]",
"functionAccessArray": "[split(variables('functionAccessFiltered'), ',')]"
},
"resources": [
],
"outputs": {
"functionAccessCsvFiltered": {
"type": "string",
"value": "[variables('functionAccessFiltered')]"
},
"functionAccessArray": {
"type": "array",
"value": "[variables('functionAccessArray')]"
}
}
}
The result:
I just had the same issue. By using an array parameter with a default value instead of a variable, I got it to work.
"parameters": {
"functionAccess": {
"type": "array",
"defaultValue": [
"value1",
"value2",
"value3"
]
}
}
I am trying to get all data from my Google Analytics account to a database using their Reporting API v4. In the below request and response, I see a number in the values attribute. I want to get member specific data for that number? For example, value is 65 for dimension 20130101. I want to get data of those 65 members that accessed my website that day (2013-01-01 - the specified dimension in the request). Any data that GA has will suffice. For example, the Gender of those 65 members, their session Id, age etc.
Google Analytics Reporting API Request:
{
"reportRequests": [
{
"viewId": "345",
"dateRanges": [
{
"startDate": "daysAgo",
"endDate": "yesterday"
}
],
"metrics": [
{
"expression": "ga:users"
}
],
"dimensions":[
{
"name":"ga:date"
}
]
}
]
}
Response
{
"reports": [
{
"columnHeader": {
"dimensions": [
"ga:date"
],
"metricHeader": {
"metricHeaderEntries": [
{
"name": "ga:users",
"type": "INTEGER"
}
]
}
},
"data": {
"rows": [
{
"dimensions": [
"20130101"
],
"metrics": [
{
"values": [
"65"
]
}
]
},
{
"dimensions": [
"20130102"
],
"metrics": [
{
"values": [
"69"
]
}
]
},
{
"dimensions": [
"20130103"
],
"metrics": [
{
"values": [
"48"
]
}
]
}
],
"totals": [
{
"values": [
"490"
]
}
],
"rowCount": 3,
"minimums": [
{
"values": [
"44"
]
}
],
"maximums": [
{
"values": [
"94"
]
}
],
"isDataGolden": true
}
}
]
}
Google Analytics reporting api don't provide single rows reports, that means that all the data that you can collect is gruped by the dimension.
In that case, if you want to retrieve al this data in a single report, you have to implement a custom dimension to a users level to identify each one, one option is send the client id (the _ga cookie) to the platform and add that dimension
Here is a good post of how to implement this
https://www.simoahava.com/analytics/add-clientid-to-custom-dimension-gtag-js/
Have in mind that you can expect others on the reports in that case, due the high cardinality.
https://support.google.com/analytics/answer/1009671?hl=en
For premium users you can export the data via BigQuery
Greetings
I am trying to automate some GTM tasks. The below code to create a "All Pages" trigger for Google Analytics works.
def CreateGATrigger(service, workspace):
"""Create the GA Trigger.
Args:
service: the Tag Manager service object.
workspace: the workspace to create the trigger within.
Returns:
The created trigger.
"""
GA_trigger = {
'name': 'All Pages',
'type': 'PAGEVIEW'
}
return service.accounts().containers().workspaces().triggers().create(
parent=workspace['path'],
body=GA_trigger).execute()
However, the below code gives me the below error. The goal of the below code is to create a custom event trigger that fires when the event variable contains "formSubmit".
def CreateformSubmitTrigger(service, workspace):
formSubmit_trigger = {
"name": 'formSubmit',
"type": 'customEvent',
'customEventFilter': [
{
'parameter': [
{
'type': 'template',
'key': 'arg0',
'value': '{{event}}'
},
{
'type': 'template',
'key': 'arg1',
'value': 'formSubmit'
}
],
'type': 'contains'
}
]
}
return service.accounts().containers().workspaces().triggers().create(
parent=workspace['path'],
body=formSubmit_trigger).execute()
Error: ( X'd out the account and container )
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/tagmanager/v2/accounts/XXXXXXXXXX/containers/XXXXXXX/workspaces/1/triggers?alt=json returned "Bad Request">
I got this to work using the below code.
def CreateformSubmitTrigger(service, workspace):
formSubmit_trigger = {
"name": "formSubmit",
"type": "customEvent",
"customEventFilter": [
{
"type": "equals",
"parameter": [
{
"type": "template",
"key": "arg0",
"value": "{{_event}}"
},
{
"type": "template",
"key": "arg1",
"value": "formSubmit"
}
]
}
],
"filter": [
{
"type": "contains",
"parameter": [
{
"type": "template",
"key": "arg0",
"value": "{{Event}}"
},
{
"type": "template",
"key": "arg1",
"value": "formSubmit"
}
]
}
],
}
return service.accounts().containers().workspaces().triggers().create(
parent=workspace['path'],
body=formSubmit_trigger).execute()
We're trying to deploy an ARM template which deploys a Stream Analytics job with n Event Hubs outputs depending on an input parameter.
Right now we're having success with all but the listKeys() function inside the outputs property copy loop function which gets each Event Hub's primary keys:
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[copyIndex('outputs')].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]"
We get the error:
17:44:31 - Error: Code=InvalidTemplate; Message=Deployment template
validation failed: 'The template resource
'tailor-router-axgf7t3gtspue' at line '129' and column '10' is not
valid: The template function 'copyIndex' is not expected at this
location. The function can only be used in a resource with copy
specified. Please see https://aka.ms/arm-copy for usage details..
Please see https://aka.ms/arm-template-expressions for usage
details.'.
However, if we change this to be a specific index:
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[0].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]"
it works.
Is copyIndex('propertyName') inside a listKeys() a supported function?
If not, is there a workaround that would achieve the same effect?
Kind regards,
Nick
Stream Analytics job resource definition:
{
"apiVersion": "2016-03-01",
"type": "Microsoft.StreamAnalytics/StreamingJobs",
"name": "[variables('routerStreamAnalyticsName')]",
"location": "[variables('location')]",
"dependsOn": [ "clientsEventHubCopy" ],
"tags": {
"boundedContext": "[variables('boundedContextName')]"
},
"properties": {
"sku": {
"name": "[parameters('routerStreamAnalyticsSkuTier')]"
},
"outputErrorPolicy": "drop",
"eventsOutOfOrderPolicy": "adjust",
"eventsOutOfOrderMaxDelayInSeconds": 0,
"eventsLateArrivalMaxDelayInSeconds": 5,
"dataLocale": "en-US",
"compatibilityLevel": "1.0",
"inputs": [
{
"name": "input0",
"properties": {
"type": "stream",
"serialization": {
"type": "Avro"
},
"datasource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"serviceBusNamespace": "[parameters('input0EventHubNamespace')]",
"sharedAccessPolicyName": "[parameters('input0EventHubSharedAccessPolicyName')]",
"sharedAccessPolicyKey": "[parameters('input0EventHubSharedAccessPolicyKey')]",
"eventHubName": "[parameters('input0EventHubName')]"
}
}
}
}
],
"transformation": {
"name": "routing",
"properties": {
"streamingUnits": "[parameters('routerStreamAnalyticsSkuTier')]",
"query": "omitted"
}
},
"copy": [
{
"name": "outputs",
"count": "[length(parameters('clients'))]",
"input": {
"name": "[parameters('clients')[copyIndex('outputs')].id]",
"properties": {
"datasource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"serviceBusNamespace": "[variables('clientEventHubNamespace')]",
"sharedAccessPolicyName": "[variables('clientEventHubClientSharedAccessName')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('clientEventHubNamespace'), parameters('clients')[copyIndex('outputs')].id, variables('clientEventHubClientSharedAccessName')), '2015-08-01').primaryKey]",
"eventHubName": "[parameters('clients')[copyIndex('outputs')].id]"
}
},
"serialization": {
"type": "Avro"
}
}
}
}
]
}
},
Thanks for reporting this and sorry for the inconvenience.
I just talked to the ARM team, we had an issue when copyindex was inside the index tags eg 'array[copyindex()]'. It should be fixed now.
Let us know how it goes.
Thanks,
JS - Azure Stream Analytics
JSON
{
"start": "2016/04/12 04:16:00",
"end": "2016/04/12 16:16:00",
"queries": [
{
"aggregator": "avg",
"downsample": "1h-avg",
"filters":
[
{
"filter": "1000009727000|1000009727018|1000009727028|10000097270404",
"groupBy": false,
"tagk": "neId",
"type": "literal_or"
}
],
"metric": "150214"
}
]
}
meet problem
“No such name for 'tagv' 10000097270404”
others tagv exist
how to solve this problem
Found the answer in https://groups.google.com/forum/#!topic/opentsdb/_47BHtew1sQ :
The default is to error out but users can set "tsd.query.skip_unresolved_tagvs" to true and it will pass the query through.
And it worked with OpenTSDB 2.3 for me.