Zapier - Create Instant Triggers - node.js

I'm using Zapier's CLI developer kit to create some app. But when I create a "new object" trigger, the url supplied in official document looks just like a "get all" trigger:
method: 'GET',
url: 'http://example.com/api/objects'
Seems Zapier won't know when a new object is created instantly, instead, Zapier checking all the objects every 5 mins.
Their plans shows even the most expensive plan can just provide checking every 5 mins.
So how can I create instant triggers? That said, I want to send a request to Zapier every time an object is created in my app.

Using Webhook also called RestHook you can create an Instant Trigger in Zapier.
If your API didn't support Webhooks then first implement webhook in your API
You can found more about the Webhooks at https://realtimeapi.io/hub/rest-hooks/
Here is a Zapier Sample APP with Instant Trigger implemented
https://github.com/zapier/zapier-platform-example-app-rest-hooks
Zapier Documentation about the RstHook
https://zapier.com/developer/documentation/v2/rest-hooks/

You need to use Webhooks if you want triggers to fire instantly.
https://github.com/zapier/zapier-platform-example-app-rest-hooks

Webhooks works greate for such by using catchook zapier method
And Sometimes for time-saving we use email as triggering emails are instant and we send the objects in subject and content then we crop them in parse or formatter

Related

Stripe API testing automation

Background
I am integrating stripe API into my site to take one off payments. My site will be API first on server side with a separate web and mobile front end. I am working on the API server side code. I will eventually use stripe payment pages to take credit card payments. I am trying to automate the testing of my APIs and am bamboozled by the documentation (which are thorough) as I just can't see what steps to take next.
My server side initiates a call with stripe using stripe sdk to create a stripe Session object - this contains a URL to redirect to checkout.stripe.com/pay/..., a success URL when payment is successful and a cancel URL (these I set to handle the callback).
Problem
I can automate in Postman all my API calls from Browse Products, Select Product, Place Order but the next step I am stuck. After Placing Order I get back the stripe session but how can I mimick making the payment with stripe for the session and then call my Success URL ?
When the site is complete I will redirect the UI to stripe to take payments but I am testing and completing the back end flow first.
I have copied and pasted the session URL which is returned by the stripe Session object to bring up the page in a browser and used Dev tools on Chrome to inspect Network to see which APIs are being called by stripe in an attempt to reproduce and I can see a POST to stripe.com/api/payment_methods and I can see the posted values but I can't reproduce this in Postman. Also, the documentation (https://stripe.com/docs/api/payment_methods/create) says
"Instead of creating a PaymentMethod directly, we recommend using the
PaymentsIntents API to accept a payment immediately"
Question
Which stripe APIs do I need to call to automate the flow from a stripe Session object to make a payment and then check that it was successful? Payment Methods? Make a Charge? Payments Intents? ...and how. Happy to be pointed to the documentation if you can help me understand the flow.
TIA
Checkout is a Stripe product that looks like a "box" and you can't know (and shouldn't need to know) what happens inside. It is created for the purpose that merchants won't have to think about what's being done under the hood.
Speaking from an automation perspective, you can try to reproduce the whole process but there's no guarantee it won't change in the future, and it could leave you with more problems later.
For options to reproduce:
The closest way is simulating browser filling and submission, using automated browser tools (ie Selenium). But it's not as straightforward as PostMan. Generally you would want to simulate every browser action that a human could do.
Or you can try to accomplish the same with the logs and events you receive on Stripe's Dashboard, when you test a Checkout Session by yourself. From now there are 3 requests.
And your goal is to receive the same 5 events in Webhook:
TBH I recommend to reconsider the need of this test, to see if it worth your efforts.

Scheduling an email with the Gmail API

I found a similar question from 2016, however at that time Gmail itself did not support scheduled sending of emails.
Now that you can schedule messages to send later directly from Gmail, I was wondering if there was a way to do it with their API.
Interestingly, scheduled emails appear as message objects when calling messages.list, but they do not contain any labels.
Any help would be appreciated! And if it's not possible at the moment, it would be awesome to get a reply from someone at Google about when this will become possible (I believe they officially endorse the gmail-api tag to StackOverflow)
I don't think a time-based trigger will work--even if you write the code to store email send data and then build something that regularly checks whether it's time for an email to be sent. See Google's documentation on triggers, and you'll notice that time-based triggers aren't available for Gmail scripts.
Unfortunately, there is no Gmail API endpoint for scheduling the sending of emails directly.
One workaround would be to write a script in Google Apps Script (https://script.google.com) which handles the composing of the email you wish to send, as well as a function to send the mail via the API. You can then use the built-in 'Apps Script Project Triggers' feature to trigger the function to run on a schedule; for example on action/event or at a specific/repeated time.
Button for adding trigger to Apps Script

Trigger a custom alert phrase (Intent) with Dialogflow

I'am new to Dialogflow, although it is easy to understand, I couldn't trigger an Intent with a custom event.
The task that I have to implement is that when an alert is detected in the backend node.js webhook (example: boss wants something done) the google assistant must alert the employee.
I tried with:
https://dialogflow.com/docs/events/custom-events
https://developers.google.com/actions/assistant/updates/notifications
But I couldn't get it to work.
Am I on the right track? or are there other solutions?
Push notifications works fine.I was able to send notifications in real time with some tolerable delai.
the following link has more details than the one on Google Actions website https://yoichiro.github.io/codelabs/actions-updates-and-notifications/?index=codelabs%2F#0

How can I trigger a dialogflow intent inside a javascript code?

I have a chatbot using dialogflow agent. I wrote a javascript back end code for its webhook fulfillment. I checked some condition in this code and if the condition is true I want a special intent to be triggered. How can I do this? What is the correct java script code to triggered an intent inside a java script if statement?
What function do you intend to perform by triggering an intent? Diaglogflow has v1 & v2 API references for this. You can do GET/POST/PUT/DELETE operations by triggering an intent using ajax call in your javascript code. Please read more about this here https://dialogflow.com/docs/reference/agent/intents
To make things clearer, DialogFlow intents are triggered by querying using the query API (https://dialogflow.com/docs/reference/agent/query)
Note: V1 of the DialogFlow API will deprecate soon, and will be replaced by V2 which is using gRPC.
This means that if you wish to trigger the intent programmatically and have the fulfilment triggered as well, you should have the following:
Script (can be on JavaScript as you would like to) with REST API request (doable using the Axios library) to the DialogFlow Query API.
DialogFlow will pick up the query, runs it through and triggers the Intent (if the query matches the intent).
In processing the intent, because there is a fulfilment, DialogFlow will run the fulfilment, which is another API/webhook call to your server hosted somewhere.
Your server will pick up the API request, and process accordingly.
Try out the Query API from DialogFlow and see if it works out for you.
Okay, I am late here, but I have used the below approach to encounter such a situation.
You can use custom event and intent chaining.
I followed the below URL and implemented the same. Maybe this help someone.
enter link description here

How to use webhooks?

I am working on a project where I need to integrate the google-services(like Gmail, Gcalendar). When the user gets a mail or something added to the gCalender I need to activate some code. Can I achieve it by webhooks or need to do polling with some time duration.
If I use webhooks, how to determine which user data that I get(consider I have thousands of users).
You can use webhooks to get push notifications. Webhooks are very similar to API's but they are inverted instead. For example instead of you making a call to an API you would define a callback URL in which the receiving end will then HTTP Post the information that you want, e.g name etc.
the creation or registration of a webhook will be the combination of:
--> a Friendly name for that webhook.
--> the URL where the callback should be sent
--> the scope of the webhook
--> the events to post to the URL either all events or a set of specific events.
Name: "MyWebhook"
URL: http://www.webhookapplication.com/webhookreciever
Scope: Project = .... and fixversion IN ("5.1")
Events: Updated and create etc.
You can create webhooks by first setting up an unique URL which I use RequestBin for e.g http://requestb.in/XXXXXXXX
Most Event Webhooks will notify a URL that you choose via the HTTP Post with information about events that occur.
A good example about webhooks can be found here:
https://sendgrid.com/docs/API_Reference/Webhooks/index.html
And this here will example how to use the send grid event to email:
https://sendgrid.com/docs/API_Reference/Webhooks/event.html

Resources