configure Gmail accounts to send notifications for mailbox updates to a topic - python-3.x

I am new to gsuite application.
I am trying to push any new email that comes to Gmail I want to push to a topic.
Here is the link i am following:
https://developers.google.com/gmail/api/guides/push#protocol
To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call.
I was not sure how it can be achieved? any sample running code will be great.do we need to write python scipt or do we need to write cloudfunction to configure, please advise?

This tutorial may be a good place to start: it walks you through the steps of enabling the Gmail API, authorizing access, and setting up Cloud Functions for watching for messages and processing incoming messages. The tutorial is in JavaScript, not Python, but it should give you a good idea of an architecture that can accomplish what you're interested in.
As for Python-specific resources: the Gmail API Python quickstart is a good place to get started making Gmail API calls. Once you have that working, you can try switching it to call watch().
Note that if you want to continue to get notifications on your Cloud Pub/Sub topic, you will need to call watch() at least every 7 days. One way to achieve this could be to use Cloud Scheduler to periodically trigger a Cloud Pub/Sub topic that in turn triggers a Cloud Function, which calls watch().

Related

FCM, send multiple devices without tokens?

I want to send FCM to everyone who installed the app. Is it essential to get everyone's tokens from the database every time?
My app is using firebase firestore overall. If there are 100,000 users,
do I have to read 100,000 from database to send fcm each time? (I think it`s little heavy stuff isn`t it?)
another workroad exists?
I wonder Is the only way to send it by putting it in the registration ID?
And can you send it on time? All apps on the market send push messages on time, but if you read 100,000 and send fcm separately, shouldn't it arrive like this at 9:01 or 9:02? But why do I always get messages at 9 o'clock?
What are the methods, logic, algorithms they use (the way companies usually use)
I still have no clue at all.
There is no "send to all users" operation in FCM. You either will have to send to each token (that's not a heave operation for FCM, which handles billions of such calls every second), or you have to subscribe all instances to a specific topic and then send to that topics (which ends up the same behind the scenes, just with Firebase loading the tokens for the topic for you).
This has been covered a few times before, so I recommend checking:
How do you send a Firebase Notification to all devices via CURL?
How to send notifications to all devices using Firebase Cloud Messaging
Firebase Cloud Messaging - Send message to all users
The notifications panel in the Firebase console has an option to deliver messages at a specific time, but no such option exists in the Firebase Cloud Messaging API. You'll have to either implement your own mechanism to schedule the delivery, or you can deliver a data message right away and then only display the notification on the device when it's time.
This also has been covered a few times before, so check:
Firebase Messaging FCM Distribution over configurable time interval
How can scheduled Firebase Cloud Messaging notifications be made outside of the Firebase Console?
Flutter Firebase Messaging: How to send push notifications to users at specified time

Send push notifications to audience defined by BigQuery result

Is any possibility trigger push notifications for specific group of users which is defined by BigQuery result. Is any way how to connect Firebase push notifications and BigQuery without programming some own backend service?
Use case is notify users based on retention other parameters queried from BigQuery.
I reached dead end in searching. So I am asking for help from someone skilled in google services or just way where to continue.
Thank you.
Unfortunately, for now, BigQuery doesn't provide a notification system. You could create a feature request here.
Alternately, you could do this using some scripting, I found an interesting Stackoverflow topic, about sending an e-mail to users defined in a BQ table, by using Firebase Cloud Functions.
I hope it helps.

Azure Bot - communicate through REST APIs

I have to integrate 2 different azure bots into a single azure bot application. So thinking of integrating with the REST api. Will this approach work ?
From this links
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-quickstart?view=azure-bot-service-4.0
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0
I can get the access token from cloud bot. But there is no example on "sending message from client". It have examples on handling client messages from server as Activity object.
It would be better if any samples on "sending message from client to azure cloud throught REST"
what is different between REST and connectors.?
I believe it will be possible with DirectLine, but wanted to know how to do thorugh REST APIs.
Thanks in Advance !!
I can't tell you whether or not your idea will work for dealing with two separate bots without more information. If you are trying to start conversations with both bots and the sending messages to the different conversations based on some set of criteria than that should work.
The Bot Framework API can essentially split into two sections:
The Connector (primary) API that the bot uses to talk to users and the service.
The DirectLine API that you can use to talk to the bot instead of using one of the built-in connectors like Slack or Teams.
Based on your needs, the DirectLine is indeed what you are looking for. The directline.botframework.com/v3/directline/conversations/abc123/activities endpoint will allow a client app to send a message to the connected bot.

Should I use Azure Service (such as Scheduler) for sending rest messages to my bot, or use a separate thread for notifications?

I am creating a bot using Microsoft Bot Framework (BotBuilder) and want it to message the user when an appointment is about to begin.
I currently use Microsoft Graph api to access the user's Office 365 calendar and store the appointments. A background thread then keeps track of time and then messages the user when an appointment is about to start.
The current idea is to use Graph webhooks to notify my bot about new appointments.
My question is, would it be smarter to use an Azure service (such as Scheduler) to keep track of the appointments, and send rest messages to my bot, which will then send a message to the user?
My worry is, that as the amount of users rise, the amount of appointments and time checks will become too large, and that maybe Azure services would be able to handle it better.
This is a perfect fit for Azure Functions with a HTTP Trigger.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook
This article explains how to configure and work with HTTP triggers and bindings in Azure Functions. With these, you can use Azure Functions to build serverless APIs and respond to webhooks.
Azure Functions provides the following bindings:
An HTTP trigger lets you invoke a function with an HTTP request. This can be customized to respond to webhooks.
An HTTP output binding allows you to respond to the request.

Is there anyway to send WhatsApp message using node js?

Is anyone aware about api that can be used to send WhatsApp message using node.
Api like whatsmate have stopped their premium services and only provide trial account.
There is no official whatsapp API, whatever you can find on the internet is "illegal" and whatsapp will ban them eventually. Check this one API who was quite good at the start:
https://github.com/venomous0x/WhatsAPI

Resources