Does the Gmail REST API have access to label colors? - gmail-api

Is it possible to get label colors through the new Gmail REST API? Many of our users color code their emails and it would be great to be able to carry that color coding over to our applications.

It doesn't as per the docs a label consists of:
{
"id": string,
"name": string,
"messageListVisibility": string,
"labelListVisibility": string,
"type": string
}
see: https://developers.google.com/gmail/api/v1/reference/users/labels
That does seem like a useful enhancement though.

python below
def MakeLabel(label_name, mlv='show', llv='labelShow'):
"""Create Label object.
Args:
label_name: The name of the Label.
mlv: Message list visibility, show/hide.
llv: Label list visibility, labelShow/labelHide.
Returns:
Created Label.
"""
bg_red_color = {'backgroundColor': '#cc3a21', 'textColor': '#000000'}
label = {
'color': bg_red_color,
'messageListVisibility': mlv,
'name': label_name,
'labelListVisibility': llv}
return label
I you need more colors go here https://developers.google.com/gmail/api/v1/reference/users/labels/create

Related

Add additional payload/ID in Facebook button in Messenger Platform

I am quite new to facebook chat bot.
https://developers.facebook.com/docs/messenger-platform/send-messages/buttons/
I can define button like this.
{
"type": "postback",
"title": "<BUTTON_TEXT>",
"payload": "<STRING_SENT_TO_WEBHOOK>"
}
I have different payload (E.g For course, student). How can I put ID information inside that button as additional information?
Do I have to define like course_1, course_2, student_5, student_8 in order to send type and ID?
The payload can contain a string up to 1000 characters, what you pass as payload is up to you. Looking at your example you could use something like "course_1" or a combination like "course_1, student_8".

Alexa Skill renders display card in Alexa companion app

How To add an image to this card or how remove it totally?
How to add an image to Alexa Card ?
Form the official documentation(https://developer.amazon.com/docs/custom-skills/include-a-card-in-your-skills-response.html#creating-a-basic-home-card-to-display-text)
A home card can include a single image. In this case, you provide the
title, text, and two URLs (a small version and large version) for the
image to display.
Note that the total number of characters (title, content, and both
URLs combined) for the card cannot exceed 8000. Each URL cannot exceed
2000 characters.
To create a card with an image, include the card property in your JSON
response:
Set the type to Standard. Set the title and text properties to the
text to display. Note that this type of card uses a text property, not
a content property like Simple. Use either "\r\n" or "\n" within the
text to insert line breaks. Include an image object with smallImageUrl
and largeImageUrl properties. Set smallImageUrl and largeImageUrl to
the URLs of a small and large version of the image to display. See
below for details about the image format, size, and hosting
requirements.
{
"version": "1.0",
"response": {
"outputSpeech": {"type":"PlainText","text":"Your Car-Fu car is on the way!"},
"card": {
"type": "Standard",
"title": "Ordering a Car",
"text": "Your ride is on the way to 123 Main Street!\nEstimated cost for this ride: $25",
"image": {
"smallImageUrl": "https://carfu.com/resources/card-images/race-car-small.png",
"largeImageUrl": "https://carfu.com/resources/card-images/race-car-large.png"
}
}
}
}
When using the Java library:
Create a StandardCard object. Call the object's setTitle() and
setText() methods to set the title and content. Create an Image object
and assign the URLs with the object's setSmallImageUrl() and
setLargeImageUrl() methods. Pass the Image object to the StandardCard
object with the setImage() method. Pass the StandardCard object to
either SpeechletResponse.newTellResponse() or
SpeechletResponse.newAskResponse() to get a SpeechletResponse that
includes the card.

Watson Conversation: Show user all entities

In Watson conversation. I have an entity Fruit
Fruit values:
-Apple
-Orange
-Banana
-Kiwi
I'd like to create a new dialog where the intent of the user is to get a list of all the values of a specific entity, in this case a list of all the fruits, . So the conversation should go:
User: "What fruits do you have?"
And then I'd like Watson to respond
Watson: "The fruits we got in store are: Apple, Orange, Banana, Kiwi"
All the stuff I found is of recognizing an entity in users input, such as
User: "Do you have apples?"
And Watson picking up Apples
Just to clarify, setting an array with the possible options declarativly on a context variable as shown below is no good for me, I need to get them dynamically from the entity
{
"context": {
"fruits": [
"lemon",
"orange",
"apple"
]
},
"output": {
"text": {
"values": [
"This is the array: <? $fruits.join(', ') ?>"
],
"selection_policy": "sequential"
}
}
}
Thankss!
AFAIK it is not possible to directly access the workspace metadata from within a dialog. You have access to what was detected using the intents, entities and context variables. However, I see two options you have:
Use your application program that drives the chat to access the entity definitions on the fly, then create a context variable in which you offer the entity choices. The API to list entities can be used from any programming language and there are SDKs.
With a relatively new feature you can invoke server or client actions from within a dialog node, i.e., make programmatic calls. Use that and the API mentioned above to obtain the list of entity values.
.

Gmail API how to get labels ThreadsUnread

how can i to get labels ThreadsUnread when excuting LabelsResource.ListRequest?
trying to get the ThreadsUnread property when i'm excuting the Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest
but it comes with null value.
This is my code:
Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest labelReq = service.Users.Labels.List("me");
IList<Google.Apis.Gmail.v1.Data.Label> labels = labelReq.Execute().Labels;
what do i need to ask in the request the ThreadsUnread or MessagesUnread value?
There is a property in the request that called "fields".
it can be set with a string. but where can i find what is the options of that string?
At the time of writing (March, 2019), you cannot get counts when doing a list. You have to subsequently request the details of each label to get the detail. Very slow, costly and frankly unnecessary. The equivalent Microsoft Graph API doesn't have this limitation.
Use the Users.labels.get. In the try-it section do this:
GET https://www.googleapis.com/gmail/v1/users/userId/labels/id
userId:
me
id:
INBOX
and execute, the response would looke something like:
{
"id": "INBOX",
"name": "INBOX",
"messageListVisibility": "hide",
"labelListVisibility": "labelShow",
"type": "system",
"messagesTotal": 1808,
"messagesUnread": 1610,
"threadsTotal": 454,
"threadsUnread": 323
}
and there's the "threadsUnread": 323 you're looking for.

Use of "creator" property in timetime insert doesn't seem to work

The playground has an example card that includes a "creator" field with the name and an image representing "Google Glass". The JSON used to create this card is
{
"text": "Hello Explorers,\n\nWelcome to Glass!\n\n+Project Glass\n",
"creator": {
"displayName": "Project Glass",
"imageUrls": [
"https://lh3.googleusercontent.com/-quy9Ox8dQJI/T3xUHhub6PI/AAAAAAAAHAQ/YvjqA3Pw1sM/glass_photos.jpg?sz=360"
]
},
"notification": {
"level": "DEFAULT"
}
}
When this is sent to Glass, however, the imageUrl isn't displayed. The documentation at https://developers.google.com/glass/v1/reference/timeline/insert simply says that "creator" is a "nested object", but with no clear indication what this nested object should be. The example seems to indicate that this should be a Contact (see https://developers.google.com/glass/v1/reference/contacts), and the object returned by the insert seems to be of type "mirror#contact", confirming this.
Does the contact used in a creator need to be pre-created via the contacts API call first? Is there something else necessary to get the creator to display or work correctly?
The creator is currently displayed only if the REPLY menu item is provided along with the timeline item.
This seems like a bug, please file it on our issue tracker

Categories

Resources