Outgoing for direct message to user

Hi everyone, it’s my first post here, i’m glad to be with you guys.

So, the point is, i’m trying to find a way to trigger my nodeJS application every time a user receives a new message, i’d made something like this for a group chat last week using outgoing for a trigger word.
I made a research and i didn’t find any post usefull so, i’m here to ask for your help.

Is it possible to user the outgoing method to this case or i need to make something like a fork that checks for a new message every second?

Thanks
Rui

Why don’t you use the API to connect to the websocket and listen live to the messages?

https://api.mattermost.com/v4/#tag/commands%2Fpaths%2F~1commands~1execute%2Fpost

You could also use the API to post messages as needed or the incoming hook after you start listening to it to delivery your messages.

Thanks prixone for the reply.

So, i want to make a call to my api method, every time that my bot account receives a new private message.

Maybe i don’t understand how websockets work, but i’m affraid that doing filters on my api will increase the number of requests what can make my api very slow.

The perfect solution will be something like the outgoing webhooks but make the trigger be “new private message of user”.

Ty

You can use an outgoing for getting the messages and the API to execute the command, that would be a single call if you have already authenticated to the API for the duration of that token.

So initializing it you would login, get token, then you can call the execute command directly without authenticating every time.

If that doesn’t fit your needs then I am afraid u will have to open a feature request so that Incoming Webhooks execute slash commands.

1 Like

It was not supposed to link to websocket, but to the execute commands, my bad, for some reason my previous reply linked to the wrong item in the API documentation, right one is:

https://api.mattermost.com/v4/#tag/commands%2Fpaths%2F~1commands~1execute%2Fpost

1 Like