How to publish my Google Business reviews updates to my topic - google-cloud-pubsub

Using the Google Cloud Platform I would like trigger a Cloud Compute function when a new review to send data to a third party system.
I have created the function that sends notications to my third party endpoint, however I am struggling hooking this into when Reviews are added to my business page.
Here's what I've done so far:
Create topic called "new-google-review"
Created subscription under topic called "new-updated-reviews"
The subscription is set to PUSH to the following endpoint URL descibed by the docs:
https://mybusiness.googleapis.com/v4/{name=accounts/*/notifications}
I'm not sure if this is quite correct, and I'm struggling to understand the documentation.

The accounts.updateNotifications is an administrative API you use to set up the notification, it is not the push endpoint you use for your subscription. The process you would use to set up this type of notification would be:
Create a Pub/Sub topic. Let's say it is projects/my-project/topics/my-topic.
Create a Cloud Function with a Pub/Sub trigger. You can do this in the Cloud Console. Choose "Cloud Pub/Sub" as the trigger type and choose the topic you created in step 1 as the topic. This will create a push subscription that triggers the Cloud Function every time a message comes through.
Make a request to https://mybusiness.googleapis.com/v4/accounts/{accountId}/notifications with a Notifications object as the body, where acccountId is your account ID. The topicName would be the topic name created in step 1 (in this example, projects/my-project/topics/my-topic) and the notificationTypes would be a list containing the single item NEW_REVIEW. You could do this as a curl request, e.g.,:
curl -X https://mybusiness.googleapis.com/v4/accounts/{accountId}/notifications -H "Content-Type: application/json" -d '{"name": "my-name","topicName": "projects/my-project/topics/my-topic","notificationTypes": ["NEW_REVIEW"]}'
though you will need to be authenticated to make that request.
If that call returns successfully, then it means that your notification has been set up properly and your Cloud Function should now trigger every time you get a new review.

Related

How to set properties for google pubsub in app?

I am trying to use google pub/sub to provide subscription service to users.
I created one topic and created one subscription(push) to verify normal operation.
But I want to add one more subscription (push), to differentiate between devServer and localServer.
I want to distinguish whether it is devServer or localServer by reading the attribute value of the message through filter.
We can differentiate this on the backend via the pub/sub Filter.
But I don't know how the app allows the user to purchase a subscription service and enter local or dev information in messages coming through rtdn.
We need your help.
Please let me know if my assumptions are wrong or if I need more information!

How to list all google directory subscription channels

I'm working on integration with Google Directory and create subscription channels to watch users updates using this API https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/watch
POST https://admin.googleapis.com/admin/directory/v1/users/watch
I created some channels and don't have their id and resourceId to stop them according to this documentation and now I can't create any new channels https://developers.google.com/admin-sdk/directory/reference/rest/v1/channels/stop
I didn't find any API endpoint to list all my current customer id channels to stop them. How can I stop any subscription (watch) channels related to the customer id so I can create new watchers?
Unfortunately, Google has not enabled support for a way to list (i.e: a LIST method) active subscriptions enabled for a given admin user/domain. The only method they've exposed is a STOP method to stop an existing subscription, but it requires the caller already know the channel metadata associated with the subscription.
The good news here is if you did not store this information upon creation, you should be able to find the required parameters as a part of an event notification. I believe they might be in the headers accompanying each notification event.

Retrieve a Chat Log watson assistant

I'm using Watson Assistant and Cloud Function in a basic chatbot. How can i retrieve via Cloud Function (node.js) the chatlog of a specific conversation? I'd like to implement this user functionality. So for example, if the user types "Chat Log", Watson Assistant send him back (via Cloud Function) his chatlog. Thanks.
In case you are using v1 version of the Watson Assistant(WA), you will get the logs via the API: https://cloud.ibm.com/apidocs/assistant/assistant-v1#listlogs
In case you are using v2 version of the Watson Assistant(WA), you will get the logs via the API: https://cloud.ibm.com/apidocs/assistant/assistant-v2#listlogs
In both of these versions, you will find a filter parameter which can be set to the current chat conversation ID or session ID and could be used to get the chat log.
Now there is a REST API that allows to get the user conversations - however this gets all users conversations so you would need to implement some kind of a proxy that would filter these logs anyway.
For this particular use case, I believe, it would be the best to log the conversations into a separate database where the data would be organized by user id. First of all - separate results for particular user can be achieved easilly in this case, second of all - in IBM Cloud in Watson Assistant the chat logs are kept for 30 days - that might not be enough for this kind of functionality.

SalesForce dynamic triggers (callbacks)

We are creating a product that allows customers to sign up and somehow "hook up" their SalesForce CRM implementation to it in which we'd like to have it automatically create triggers/callbacks to an endpoint URL we own (and transferring info about the action+details and which customer of ours is triggering it).
For example: when someone enters a lead, a sale, etc. we want our service (custom code elsewhere on HTTP REST endpoint) to be notified.
What is the best approach for this? I'm a newbie when it comes to SalesForce, just looking for someone to push me the right direction. I hear "SalesForce Apps" and then there is an API, etc. I also hear there is an API limit, so is polling a better idea? Anything else I am missing?
If you distribute your application or "connector" through the Salesforce App Exchange then you can have an Apex trigger on some SObjects which does an HTTP / REST callout to your service. Otherwise you could do something similar to how the Salesforce Webhook Creator dynamically generates the necessary Apex and adds it to a Salesforce org (via the Salesforce Tooling REST API).

Send Email When Match in Firebase Database

I'm trying to build a web app using AngularJS and Firebase that sends an email to two users that match on certain parameters. The users submit their information first and if there is a match with another person in the database, I want to send an email to both those people. For example, if two people, A and B both have the age of 25, I would like to send A and B an email with certain information. Is this possible using Firebase?
If you are NOT running a server
Yes
You could achieve it by using a service like Zapier.
You could create a zap linking FireBase and an e-mail service like Mandrill.
A Zap combines triggers and actions — whenever the trigger event occurs, Zapier automatically completes the action for you!
When there is a match, update a special key in your FireBase database.
As Zapier is listening to updates of that particular key, it will react by sending your e-mails via Mandrill.
March 2017 UPDATE
New tools have now been added to Firebase to trigger database event handlers:
database events triggers: https://firebase.google.com/docs/functions/database-events
cloud functions for FireBase: https://firebase.google.com/docs/functions/functions-and-firebase
using cloud functions to send e-mails through sendGrid:
https://cloud.google.com/functions/docs/tutorials/sendgrid
If you are running a server
Your server can easily check the values in FireBase and send e-mails accordingly. That would then be a
Yes, of course :)

Resources