How is an event triggered through Message Server to GraphQL?

I need to send Products out of SambaPOS. Each Product is created in SambaPOS, I want to run a node query that’ll do something (send it to another app after querying it with GraphQL).

How can Message Server/Nodejs sense this event?

What event? Creating a product?
Don’t think there are any events for admin managment setting changes.

What about ticket creation?

I see the Gloria App has a loop. Is this the standard way?

function loop() {
    if (!accessToken) {
        console.log('There is no valid access token. Skipping...')
        Authorize();
    }
    else if (accessTokenExpires < new Date()) {
        console.log('Access Token Expired. Reauthenticating...');
        Authorize(() => loop());
        return;
    }
    else {
        console.log('Reading Tickets...');
        readTickets((tickets) => processTickets(tickets));
        console.log();
    }
    setTimeout(loop, timeout);
}

Edit
it seems the action is coming from Gloria for

graphQL will return a response to whatever app your developing… you can then use that response to do whatever you need to do. I am not really sure what you are asking here. If your asking how do you access graphql please read the tutorial you already posted in.

Are you wanting to communicate to your app when an event in SambaPOS is triggered? You dont even need graphql for that if so.

Yes. I’d like to duplicate certain records into ERPNext as they’re created/updated in sambapos. Products, users, tickets, payments, etc

Tickets and payment events can be triggered from automation in samba.
Products and users wont have an event in automation but products could be queried at any time through api or sql.
Not sure if users can be called in api but definitely with sql.
Also you can run custom reports api also so may be useful for some things.

Do you think the automation rules inside sambapos can initiate or execute the API/nodejs code?

Well you can run a script from almost anywhere in automation and there are helper handlers for allot of functions… actual examples would.be easier to follow.

Where can I find such examples or a guide for Automation scripts?

Automation is a big subject, is main part of power of samba.
Still don’t understand what it is your trying to do which might help with context and sugestions.
Maybe look at my PMS integration topic for some ideas.

You can execute jscript and access graphql directly inside Sambapos. I still am confused with what your trying to do.

I am trying to replicate records (Product Group, Product, Payment Options, Ticket, Payment) in SambaPOS to ERPNext. For instance for Ticket, my plan is:

  1. Trigger the script on creation of ticket
  2. Query SambaPOS Ticket and its Products using a script (jscript or nodejs) with (GET) Graphql queries
  3. Script PUTs Ticket and its Products into ERPNext using REST API

My plan has been to run this as these records are created in SambaPOS so that I avoid the problem of figuring out what has already been sent.

My general understanding is that the Message Server should “broadcasts” certain actions such as ticket created. I was hoping to intercept this message using my custom script and send it to ERPNext with REST, but I haven’t found any documentation on how Message Server can be used in this context.

No. You are looking wrong side.
MessageServer have 2 independert parts. First is a SignalR server. This part is using from Samba terminals. But it doesnt brodcast all actions.
Second is a GraphQL server. So you can query SambaPOS Db with this. Also you can record a lot of things over mutation commands.

Im not sure about api and message server as an out from samba route/trigger.
You could easily trigger from automation as said before.
From your example there you simplest solution would be a script on ticket closing event with remain balance=0 (ie finnished ticket) to generate the json or whatever and post to your api.
Not sure why you want a middleman for this scenario unless looking to create SAS.

Again I sugest you look at my PMS intergration.

It directly syncs sales with the hotel booking system.
Been 3 years and probably 2mil of transactions with only few minor issues usually relating to user errors.

Thanks @JTRTech

I’m looking into this, yes I think a script would be ideal. Really not looking into creating anything unnecessary, I just need a quick and simple solution for this issue

@VehbiEmiroglu
Interesting. I would like to learn more about this Message Server, at least just for a full understanding of how it works. A colleague implemented something similar with a RabitMQ, an open source message server.