is it possible to send notifications when i insert to a mongodb database with Nodejs and send a notification to a react native app using OneSingnal? how could it be done?
I have the part of the mobile, I can already send tests from Onesingnal to my mobile but I need that when I make an insert to from Nodejs I send a notification to the mobile
Thanks for you help
Yes This can be done.
from your question I can see that you are using a Node.js based API and calling it from mobile.
Step 1 : Get the player ID
You can get the player ID using the event listener response of OneSignal.addEventListener('ids', this.onIds); - the device details would be passed to onIds function as an argument
Step 2 : Save it along with your user details
You can have a mapping to your user and playerid somewhere in your database
Step 3 : Use the Rest API to notify users after the data entry succeeds
The documentation for the rest api can be found here
https://documentation.onesignal.com/reference#create-notification
The above steps are required only if you want to target a user, you can directly send a notification to all using the appid and the playerid wont be required in that case.
Related
is there an api on shopify where I can see real time when data changes ? Maybe I have a node server and I use sockets to see when anyone has bought anything from my shop that I get a notification via nodejs on my backend. is it possible ? a few websites has this, they offers you to sell on their site and you can see real time changes data when anything was bought
Yes, you can subscribe to multiple Webhooks to get notified when a change occurs on your shop. Using the REST Admin API, available webhook event topics include:
orders/create: occurs whenever an order is created / someone buys from your shop.
orders/paid: occurs whenever an order is paid.
orders/fulfilled: occurs whenever an order is fulfilled.
orders/cancelled: occurs whenever an order is cancelled.
Use the /admin/api/2023-01/webhooks.json endpoint to subscribe to a webhook:
// Node.js - Session is built by the OAuth process
const webhook = new shopify.rest.Webhook({session: session});
webhook.topic = "orders/create";
webhook.address = "https://example.hostname.com/";
// format you want to receive the event data in
webhook.format = "json"; // or XML
// fields you want to receive
webhook.fields = [
"id",
"note"
];
await webhook.save({
update: true,
});
You can also use the GraphQL Admin API for the same purpose.
SDK
Homepage: https://github.com/Microsoft/BotBuilder
SDK Platform: Node.js
SDK Version: 3.14.0
Issue Description
Hi, I searched for this for a long time now but I haven't found an answer.
I was wondering if there is a way to bind some URL parameters to the User's Bot Session.
For example, if for a specific chat dialog, I set my Endpoint URL to:
http://localhost:3978/api/messages?pronuntiation=british
is there a way to get that url parameter named "pronuntiation" down in the session object like...
bot.dialog("/", function(session){
var desiredPronuntiation = session.someUrlParameters.pronuntiation;
if( desiredPronuntiation == "british"){
///blah
}
});
I think it is possible in C# SDK but I was trying to do this in NodeJS...
I already debugged the proces from the server.post('/api/messages', connector.listen()) down to the ChatConnector.verifyBotFramework() where at the end I found it calls _this.dispatch(req.body, res, next); (ChatbotConnector.js on line 149) passing only the post body but not the request object itself...
So at a first glance I think this is not possible, I just wanted to be sure that I didn't miss anything...
Thanks,
Luis
As far as I know, this isn't supported by the Bot Framework, however I don't see why you need to do it this way. This is something you want to store in the state, for example the userData. You can read more here about managing state in the Bot Framework.
If you want to pass user data to the bot, it depends on the channel. For example Facebook and Webchat allow you to pass data direct to the bot, without user input.
I'm learning how to build a Microsoft Bot and I need to send every message (ie log the user progress through the bot) to an API.
Let's say I have these dialogs with 3 steps each:
/
/welcome
/onboarding
/finish
When a user joins the conversation (Root dialog), I need to make a POST to our API with the following data:
{
"conversationId": "8n21b2mkmdb9abi26",
"dialog": "root",
"step": 1
}
And then, for each following user message, I would update that conversation in our server with the dialog and step.
I tried to use the middleware hook, but it doesn't have the information of which dialog/step the user is currently in.
Any suggestion?
The middleware feature gives you access to the session object. Store the metadata you need in the session object, then access it in your logging middleware.
For a code example, check out: Microsoft/BotBuilder-Samples - Middleware and Logging with BotBuilder Node SDK
Hello i'm newbie and im hardly to understand this notification in service-worker, and because my knowledge isn't good yet then probably i will unable to explain my problem clearly.
so here's the code :
// triggered everytime, when a push notification is received.
self.addEventListener('push', function(event) {
console.info('Event: Push');
var title = 'New commit on Github Repo: RIL';
var body = {
'body': 'Click to see the latest commit',
'tag': 'pwa',
'icon': './images/48x48.png'
};
event.waitUntil(
self.registration.showNotification(title, body)
);
});
this is the code that trigger to POP the notification, what I do not understand is where the argument to accept/ receive the data ?
I've been searched a lot: https://auth0.com/blog/introduction-to-progressive-web-apps-push-notifications-part-3/ ,
https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web
there's some new data JSON or from git-server or push api, but I still hardly to understand where's to accept the data.
sorry if you still do not understand what's my problem.
Here to make it simple what I want :
Let's say i make a button, and everytime i click the button it will value as 'True' and I want that 'True' value to pass into argument and trigger the push of notication in service-worker.
2nd questions: am I able to trigger notification with header or text in html ? since we can manipulate the text with DOM ?
am I able to trigger notification without GCM, or API cause I just want a simple notification in serivce-worker like above without passing much data.
If you give more advice or maybe notification without service-worker but real time , I am surely happy to read it but I hope Im able to understand.
There are basically two concepts involved that work well together but can be used independently. The first is the visible UI shown to a user that tells them information or prompts them for an action. The second is sending an event from a server to the browser without requiring the user to currently be active on the site. For full details I recommend reading Google's Web Push docs.
Before either of those scenarios you have to request permission from the user. Once permission is granted you can just create a notification. No server or service worker required.
If you want to send events from a server you will need a service worker and you will need to get a subscription for the user. Once you have a subscription you would send it to a server for when you want to send an event to that specific browser instance.
Once you receive a push event from a server you display the UI the same as in the first scenario except you have to do it from the service worker.
I'm using Web push notifications with Chrome, and they work great. But now I want to deliver a custom message in my notifications. I can have my Service Worker call out to my site to get content, as is done at https://simple-push-demo.appspot.com/—which is fine if I want every recipient to see the same message.
Is there any way to get either the recipient’s registration_id or the message_id that GCM returns? If I could get either of these and include them in the callback to the service, I could customize the response.
Also, any info on when we might be able to include a payload in the call to GCM?
The registration_id and message_id fields aren't exposed, but if the user is previously authenticated to your app, any fetch() to the server from your Service Worker will include credentials (and session information) which you can use to identify them.
If that doesn't work for your case, you can store user/session information in IndexedDB.
Payloads are coming soon—likely Chrome 50 or 51—based on the Web Push protocol. It's a bit of extra overhead and work to configure the (required) encryption.
It's possible, but I wouldn't do it since it's specific to GCM, while other browsers use other services.
You can either create a unique ID for each user (like we're doing in Mercurius) and store it in IndexedDB, or you can use the entire endpoint URL as an ID.
Here's the snippet to get the registration_id:
self.registration.pushManager.getSubscription()
.then(function(subscription) {
if (subscription) {
var endpoint = subscription.endpoint;
var endpointParts = endpoint.split('/');
var gcmRegistrationID = endpointParts[endpointParts.length - 1];
console.log(gcmRegistrationID);
}
});
P.S.: It returns a promise, so make sure your service worker waits for the promise to be resolved.