Currently i am creating a chatbot for skype using Dialogflow the main problem is when i use the command "Now" in a skype message it uses my current time +1 hour, but when i ask for the time "Now" from the IOS Application it use the current correct TimeZone, someone knows from "where" exactly dialogflow takes the current time zone for the word "Now" because from my app-IOS because from the IOS_Application it gets one value (Correct timezone value) and from skype it gets a another(timezone + 1 hour value)
Raw Interaction Log(Dialogflow - Skype):
{
"queryText": "what time is now?",
"parameters": {
"time": "StiDate [Thu Oct 18 12:38:16 CDT 2018]"
},
"fulfillmentText": "the time is 12:38:16",
"fulfillmentMessages": [
{
"text": {
"text": [
"[{\"type\":0,\"speech\":\"the time is 12:38:16\"}]"
]
}
}
],
"intent": {
"id": "37524c80-a15a-4c04-aa9b-38986ff38993",
"displayName": "A_Test_EventTime"
},
"languageCode": "en",
"sentimentAnalysisResult": {},
"id": "93ce9408-4b73-4f18-9ae0-b947a906afc8",
"sessionId": "6b69769b-1ce7-4359-9018-c88d017485bf",
"timestamp": "2018-10-18T17:38:16.164Z",
"source": "agent"
}
Raw Interaction Log(Dialogflow - AppIOS):
{
"queryText": "What time is now?",
"parameters": {
"time": "StiDate [Thu Oct 18 11:38:00 CST 2018]"
},
"fulfillmentText": "the time is 11:38:00",
"fulfillmentMessages": [
{
"text": {
"text": [
"[{\"type\":0,\"speech\":\"the time is 11:38:00\"}]"
]
}
}
],
"outputContexts": [
{
"name": "fa75fc39-7c68-47ac-bea5-12394f425855",
"lifespanCount": 4,
"parameters": {
"time.original": "now?",
"time": "StiDate [Thu Oct 18 11:38:00 CST 2018]"
}
}
],
"intent": {
"id": "37524c80-a15a-4c04-aa9b-38986ff38993",
"displayName": "A_Test_EventTime"
},
"languageCode": "en",
"sentimentAnalysisResult": {},
"id": "58ade82b-c842-44b6-b0a2-d6cced4d6648",
"sessionId": "dfe0efda53d11aa3d8d43e92a726f9e4",
"timestamp": "2018-10-18T17:38:00.695Z",
"source": "agent"
}
Dialogflow agents have a default time zone. You can change this time zone in your Dialogflow's agents settings in the console: https://dialogflow.com/docs/agents/create-manage#general
Related
I need to use the Google API in order to retrieve the first time an email was marked as view (Specifically, when an email was opened).
I'm using GET https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/{id} requesting only the metadata to get the messages but the response looks like this:
{
"id": "17a05bd8db1609b9",
"threadId": "17a05bd8db1609b9",
"labelIds": [
"CATEGORY_PROMOTIONS",
"UNREAD",
"INBOX"
],
"payload": {
"partId": "",
"headers": [
{
"name": "Delivered-To",
"value": "{EMAIL ADDRESS}"
},
{
"name": "Received",
"value": "by 2002:a55:c51e:0:b029:e9:12c1:65a9 with SMTP id b30csp1876084egk; Sun, 13 Jun 2021 07:19:06 -0700 (PDT)"
},
{
"name": "X-Google-Smtp-Source",
"value": "ABdhPJzPcWJR1zsvAH654luf+agnL6i6CGj8S/jO1MDZVz3yPHcqE7y37chZ7euL02n40t6idUB/"
},
{
"name": "X-Received",
"value": "by 2002:a9d:62ce:: with SMTP id z14mr10328566otk.255.1623593946243; Sun, 13 Jun 2021 07:19:06 -0700 (PDT)"
},
{
"name": "ARC-Seal",
"value": "i=1; a=rsa-sha256; t=1623593946; cv=none; d=google.com; s=arc-20160816; b=L8L+Vz979TjsIDtXAyhnPBQUmW8Njjz+DiyScOHFvyHbmOC9sIyaH5AFOafzFou45N nTtpzyq9pSlZ8VWd6N9N+NYcdldf67A7/FarG9iIs6EvddVYcpbEqdTPOyMt6/mluVQO utRoX3ma1TFAIyXoQLvxfPZ5QZLZNQFpPwYWGIkB+/8r45OKkqhuWtX8d93InKgpoVIf NQjaI4Tnr2AJWWJjiALL8bLoCe1QvA3mV+I1sTbGRPZAIPcKfm+nB3smYgkH7f9C+1+8 iXR/45AWh+9Sxd1IFrHHokfTEOQvHEWDXm8BBagCFaRFJv45V+FIyWGJKKpL4UCI0oab 7ZRg=="
},
{
"name": "ARC-Message-Signature",
"value": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe-post:list-unsubscribe:mime-version:subject :message-id:to:reply-to:from:date:dkim-signature:dkim-signature; bh=3CtcdJdIFbH5c/+55q2hcIqL8foXcatroOK85FVqTxk=; b=0/F/Qn1AmdXlp7t9Or1qvUB+6xmvr2Ewxm33BtMBo956QCvgQQ5qilxt3ZI1Kqx+YB zuQZLKRcG7T1kRqvsq3ERdrAqAr6P8+I6j9yWw6XaI7uuU8crVbnEjbkUAheFjmNeXOP ZcuwtlUPlgDiyOmE6ND2HWLrpUcCKxx/TY17fYkR/H08yr44BqtTXSJVUG12n5Sjb8iA nnFyJHYBRg2Elw7vMnUl+wiO0k1EH9C7ltwTJCjVsDPe0LcvcjtDcr0R4i24sYbNTDgN fyOsKMfJnPAE/oLk6iZhd0NvWVkUUvop6b8kdZtLfVH1jLMIYPBOlNjeSct+yfmtrHWt Vrwg=="
},
{
"name": "ARC-Authentication-Results",
"value": "i=1; mx.google.com; dkim=pass header.i=#emails.waves-audio.com header.s=gears header.b=AAcEguTx; dkim=pass header.i=#d.messagegears.io header.s=gears header.b=jvFNHriZ; spf=pass (google.com: domain of 346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com designates 135.84.217.27 as permitted sender) smtp.mailfrom=346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com"
},
{
"name": "Return-Path",
"value": "\u003c346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com\u003e"
},
{
"name": "Received",
"value": "from mta0201-27.emails.waves-audio.com (mta0201-27.emails.waves-audio.com. [135.84.217.27]) by mx.google.com with ESMTPS id t22si9652818otl.163.2021.06.13.07.19.06 for \u003c{EMAIL ADDRESS}\u003e (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 07:19:06 -0700 (PDT)"
},
{
"name": "Received-SPF",
"value": "pass (google.com: domain of 346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com designates 135.84.217.27 as permitted sender) client-ip=135.84.217.27;"
},
{
"name": "Authentication-Results",
"value": "mx.google.com; dkim=pass header.i=#emails.waves-audio.com header.s=gears header.b=AAcEguTx; dkim=pass header.i=#d.messagegears.io header.s=gears header.b=jvFNHriZ; spf=pass (google.com: domain of 346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com designates 135.84.217.27 as permitted sender) smtp.mailfrom=346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com"
},
{
"name": "DKIM-Signature",
"value": "v=1; a=rsa-sha256; c=relaxed/relaxed; s=gears; d=emails.waves-audio.com; h=Date:From:Reply-To:To:Message-ID:Subject:MIME-Version:Content-Type: List-Unsubscribe:List-Unsubscribe-Post; i=news#emails.waves-audio.com; bh=3CtcdJdIFbH5c/+55q2hcIqL8foXcatroOK85FVqTxk=; b=AAcEguTxQVhKb8tKVqR1lfLjeU7RxkHAe91vfNVg5UdOTOvGfi+oPi4wnn3dR/XUuFYxu47u9Cfo g+jeKSONECg68D/xEtQCnf0MfO71lKSLXDghlYhhaAh5Jjd2IH88b+2hM5fBFN7Fz7lDUp1+Bw/0 U9IH4Ei+w7E8RXs/D6E="
},
{
"name": "DKIM-Signature",
"value": "v=1; a=rsa-sha256; c=relaxed/relaxed; s=gears; d=d.messagegears.io; h=Date:From:Reply-To:To:Message-ID:Subject:MIME-Version:Content-Type: List-Unsubscribe:List-Unsubscribe-Post; bh=3CtcdJdIFbH5c/+55q2hcIqL8foXcatroOK85FVqTxk=; b=jvFNHriZksLExFsp7Br0sf598nLFywhbNS7N+70VY0zeKKLxvm0G4EKNUJ3Fe+3a5oWYWa7HBcJS vq8hAERdI6vQjNNZHYJifHodm4+B04CXCDev9Il3Sx3qB+CYDYymKyeiEycsHWejCdJilo8HN+GE Cxv+AtCFwq2s68gY/r0="
},
{
"name": "Date",
"value": "Sun, 13 Jun 2021 10:04:23 -0400 (EDT)"
},
{
"name": "From",
"value": "Waves Audio \u003cnews#emails.waves-audio.com\u003e"
},
{
"name": "Reply-To",
"value": "Waves Audio \u003cnews#emails.waves-audio.com\u003e"
},
{
"name": "To",
"value": "{EMAIL ADDRESS}"
},
{
"name": "Message-ID",
"value": "\u003c618286522.102678350.1623593063602.JavaMail.cloud#mta0201.messagegears.net\u003e"
},
{
"name": "Subject",
"value": "ENDS TODAY ⏰ ALL Compressors $29.99"
},
{
"name": "MIME-Version",
"value": "1.0"
},
{
"name": "Content-Type",
"value": "multipart/mixed; boundary=\"----=_Part_102678347_1640882403.1623593063602\""
},
{
"name": "X-Original-To",
"value": "{EMAIL ADDRESS}"
},
{
"name": "List-Unsubscribe",
"value": "\u003chttp://track.waves-audio.com/list-unsub/uc/2/1cla%3ANDYwNjQ2MzY%3AMDItYjIxMTY0LTgzZDZiZTJiZGM0NTQyZjdhNTc0OTI0MjQ1MDIwYzVl%3AYXJzZXJlZ0BnbWFpbC5jb20%3AMTY1NjkwNQ%3An%3An%3A_8LcuFe86CJ4F5wm08TiWA\u003e, \u003cmailto:unsub-346064636000c23595702-b21164-83d6be2bdc4542f7a574924245020c5e#emails.waves-audio.com\u003e"
},
{
"name": "List-Unsubscribe-Post",
"value": "List-Unsubscribe=One-Click"
}
]
},
"sizeEstimate": 51137,
"historyId": "6952408",
"internalDate": "1623593063000"
}
And this doesn't show any field like First opened, nor anything similar.
The other approach I was thinking about was checking the history of Labels of the message, if I'm able to retrieve the date at which the UNREAD labelId was added, I would be able to determine the time the email was viewed.
Issue:
In Gmail API, there's no direct way to retrieve the date a certain message was read.
In Gmail itself, there's the option of requesting a read receipt, but this doesn't automatically apply to all emails, and is not available to the API either (consider filing a feature request in Issue Tracker for this).
Using users.history you can track changes to labels (e.g. UNREAD), but the related History resource does not include information on the dates these label changes occurred, so it would not be useful for your situation either (apart from this, history records expire after a short time, typically around one week or a bit more - see Limitations).
Workaround:
Taking all this into account, I think currently the best approach would be to develop a Workspace Gmail add-on. With this, you can add a contextual trigger that fires a function every time a message is opened (as long as the add-on is being used).
The fired function could then be used to store the current date as well as the messageId (for example, using PropertiesService. This way, you could keep track of the dates each message was opened. In this case, the messageId (or the threadId, for that matter), could be retrieved in your function thanks to Gmail event object.
More specifically, you contextual function could be something along the following lines:
function onGmailContextual(e) {
const messageId = e.gmail.messageId;
const userProps = PropertiesService.getUserProperties();
let dateRead;
const messageProp = userProps.getProperty(messageId);
if (messageProp) { // If it exists, the message was read before
dateRead = new Date(JSON.parse(messageProp)); // Retrieve previously store read date
} else { // If it doesn't exist, the message was not read before (at least while the add-on was open)
dateRead = new Date(); // Get current date
userProps.setProperty(messageId, JSON.stringify(dateRead.getTime())); // Store current date as reading date for this message
}
// ...
}
Please note that this will only work for messages opened when the add-on is opened, so you cannot use this to retrieve reading dates for old messages.
Further reading:
Extending Gmail with Google Workspace add-ons
Build contextual message interfaces
Install an unpublished add-on
I am running into an issue creating recurring events in the past using Graph API. When I POST this data to /me/calendars/[calendarId]/events I get an ErrorPropertyValidationFailure error:
{
"isAllDay": true,
"start": {
"timeZone": "America/New_York",
"dateTime": "2000-09-02"
},
"end": {
"timeZone": "America/New_York",
"dateTime": "2000-09-03"
},
"subject": "Jimmy's birthday",
"body": { "contentType": "text", "content": "" },
"isCancelled": false,
"recurrence": {
"pattern": {
"type": "absoluteYearly",
"interval": 1,
"dayOfMonth": 2,
"month": 9
},
"range": { "startDate": "2000-09-02", "type": "noEnd" }
},
"showAs": "free",
"type": "seriesMaster"
}
All of the data seems valid to me, and indeed just changing the start and end dateTime values and the recurrence range's startDate to be in 2019 instead of 2000, and it seems to work.
But here's where it gets weird: keep those values in 2000, and change the dayOfMonth in the recurrence pattern to an incorrect value, like 5. Then when submitting to the API, it works! The recurrence will instead appear to begin on Sep 5 of 2000 and there is nothing on Sep 2 (also, the event seems to run "Tue 9/5/2000, 11:00 PM to Wed 9/6/2000, 11:00 PM" on the calendar, which is strange, since it also appears as an all-day event).
So my question is: is this a bug? Or what the heck's happening? It looks like correct data is getting a validation error, but incorrect data creates an event.
Updating to add the error body:
{
"error": {
"code": "ErrorPropertyValidationFailure",
"message": "At least one property failed validation.",
"innerError": {
"date": "2020-10-15T22:48:50",
"request-id": "c08b1d73-5b6d-46ac-8751-d1f17310f652",
"client-request-id": "c08b1d73-5b6d-46ac-8751-d1f17310f652"
}
}
}
Hello I'm building a bot in skype using api.ai, or dialogflow, as it is called now. Anyway, this is my custom payload:
{
"skype": {
"type": "",
"attachmentLayout": "",
"text": "",
"attachments": [
{
"contentType": "",
"content": {
"title": "",
"images": [
{
"url": ""
}
],
"buttons": [
{
"type": "",
"title": "",
"value": ""
}
]
}
}
]
}
}
And here is my webhook response:
"data": {
"skype": {
"type": "message",
"attachmentLayout": "carousel",
"text": "Here you go!",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Italian Cassoulet (Italian Chili)",
"images": [
{
"url": "http://img.food.boxspace.in/image/rbk_57139479f2705/hdpi.jpg"
}
],
"buttons": [
{
"type": "openUrl",
"title": "View Recipe",
"value": "http://recipebk.com/Share.html#url=rbk_57139479f2705"
}
]
}
}
]
}
}
}
Now, if I embed this response I get the result as a carousel of cards on skype. but when I try the same with my webhook, no message is displayed. Can someone tell me what I'm doing wrong? Already check this Stackoverflow question and this api.ai link , but it's been of no use so far.
Alright, so if I get this correctly, creating the response on the API.ai online console works, but when you generate the json from your webhook it fails?
Just for reference, it's maybe a bit difficult to test but in the online console you can click the "default response" on the right where you'd test your intents to "skype". This way, you could look at the error message at the bottom to see if there's any error and why.
Now that that's cleared out of the way, even if the documentation says you should embed custom payloads from the webhook in the data field, I simply don't. I simply follow the exact same way API.ai generates the response by overriding the message field in the webhook response. As examples say more than words, I'll give you the full webhook response that creates a couple of lists of richcards for one of my chatbot intents. As you notice, I put everything in the message field of the Json.
{
"speech": "",
"displayText": "",
"data": {
},
"contextOut": [
],
"source": "Webhook",
"messages": [
{
"type": 4,
"platform": "skype",
"speech": "",
"payload": {
"skype": {
"attachmentLayout": "list",
"attachments": [
{
"contentType": "application\/vnd.microsoft.card.hero",
"content": {
"title": "Unit 2A",
"subtitle": "",
"text": "These timeslots are available for 2017-10-16",
"images": [
],
"buttons": [
{
"type": "imBack",
"title": "from 13:00 until 14:00 Unit 2A",
"value": "from 13:00 until 14:00 Unit 2A"
},
{
"type": "imBack",
"title": "from 14:00 until 15:00 Unit 2A",
"value": "from 14:00 until 15:00 Unit 2A"
},
{
"type": "imBack",
"title": "from 15:00 until 16:00 Unit 2A",
"value": "from 15:00 until 16:00 Unit 2A"
}
]
}
},
{
"contentType": "application\/vnd.microsoft.card.hero",
"content": {
"title": "Unit 1",
"subtitle": "",
"text": "These timeslots are available for 2017-10-16",
"images": [
],
"buttons": [
{
"type": "imBack",
"title": "from 13:00 until 14:00 Unit 1",
"value": "from 13:00 until 14:00 Unit 1"
},
{
"type": "imBack",
"title": "from 14:00 until 15:00 Unit 1",
"value": "from 14:00 until 15:00 Unit 1"
},
{
"type": "imBack",
"title": "from 15:00 until 16:00 Unit 1",
"value": "from 15:00 until 16:00 Unit 1"
},
{
"type": "imBack",
"title": "from 16:00 until 17:00 Unit 1",
"value": "from 16:00 until 17:00 Unit 1"
}
]
}
}
]
}
}
}
]
}
Do note however that API.ai will simply override the messages this way and passes it along to skype. For more information about richcards you could read: https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-add-rich-cards and use the Json structure in your api.ai webhook.
I've given the full example as it's very difficult for me to test your setup the way you provided your question, also API.ai is a blackbox in some cases with undocumented features...
I am trying to figure out how to get the number of returning users over a custom date range using the V4 Reporting API.
Like the 'All Users' row in this screenshot, but instead of the last 14 days, it should be any date range.
After reading through the documentation, the only thing I came up with, was to create cohorts for every day I want to query, and then sum up the values for each day to get the totals:
"reportRequests": [
{
"viewId": "147125344",
"dimensions": [
{
"name": "ga:cohort"
},
{
"name": "ga:cohortNthDay"
}
],
"metrics": [
{
"expression": "ga:cohortActiveUsers"
}
],
"cohortGroup": {
"cohorts": [
{
"name": "date 1",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"endDate": "2017-07-08",
"startDate": "2017-07-08"
}
},
{
"name": "date 2",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"endDate": "2017-07-09",
"startDate": "2017-07-09"
},
{
"name": "more days",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"endDate": "next day",
"startDate": "next day"
}
}
]
}
}
]
}
However, this is limited by the fact that there can only be 12 cohorts in total, so I could not query more than 12 days at once.
Is there any way to get this data directly through the API?
I'm trying out rethinkDB and playing around with some query to see if it could fit by use case. So far, so good. However, I have a question regarding reQL.
For example in this case I store analytics events in rethinkDB such as:
[{
"userId": "abdf213",
"timestamp": "Sat Jan 17 2015 00:32:20 GMT+00:00",
"action": "Page"
},
{
"userId": "123abc",
"timestamp": "Sat Jan 17 2015 00:42:20 GMT+00:00",
"action": "Track"
},
{
"userId": "abdf213",
"timestamp": "Sat Jan 17 2015 00:45:20 GMT+00:00",
"action": "Track"
},
{
"userId": "123abc",
"timestamp": "Sat Jan 17 2015 00:44:20 GMT+00:00",
"action": "Page"
},
{
"userId": "123abc",
"timestamp": "Sat Jan 17 2015 00:48:20 GMT+00:00",
"action": "Page"
}]
I'd like the end result of my query to look like this:
{
"group": "123abc",
"reduction": {
"Page": 2,
"Track": 1
}
},
{
"group": "abdf213",
"reduction": {
"Page": 1,
"Track": 1
}
}
Bear in mind that the action name are not known in advance.
TBH, I'm not quite sure how to achieve this with ReQL.
Right now I have this query (using the data explorer):
r.db('test').table('events').group('userId').map(function(event) {
return event('action')
})
which return doc like this one:
{
"group": "-71omc5zdgdimpuveheqs6dvt5q6xlwenjg7m" ,
"reduction": [
"Identify" ,
"Page" ,
"Track"
]
}
Anyone can point me in the right direction here?
Cheers,
S
Try:
r.table('events').group('userId').map(function(event) {
return r.object(event('action'), 1);
}).reduce(function(a, b) {
return a.merge(b.keys().map(function(key) {
return [key, a(key).default(0).add(b(key))];}).coerceTo('object'));
})
Here's my solution:
r.table("events").group("userId", "action").count().ungroup()
.group(r.row("group")(0))
.map([r.row("group")(1), r.row("reduction")])
.coerceTo("object")
ReQL doesn't support nesting groups, but you can group by multiple fields at the same time and then performing further grouping on the output.