Operational

DocsGithub Open app

Operational

Github Articles Pitch Usecases Playground API

Contents

Start hereSetup Operational
The Manual
IntroductionPWA & push notificationsConventionsSetupTest modeNotifications
Integrations
Nodejs SDKPHP SDKWordpress plugin
Events API
IntroductionSend your first eventEvent parametersStructured EventsActionsContextsCategoriesError handling
Self hosting
IntroductionInstall locallyInstall on VPSInstall on RenderInstall via DockerInstall via Docker and CoolifyOnboardingSetup .envSetup PWA & push notificationsBest practices
Other
VisionRoadmapContributing

Sending actions in events

Action are objects that will render Action buttons inside the event UI. Pressing these buttons will send a webhook to your server.

Here’s a simple example:

const e = {
  name: "a critical event",
  avatar: "🤖",
  actions : [
    {
      url : 'https://webhook.site',
      buttonText : 'Press me'
    }
  ]
};

You can also have static buttons which simply open up a webpage. Here’s another example:

const e = {
  name: "a critical event",
  avatar: "🤖",
  actions : [
    {
        url : 'https://stripe.com',
        external : true,
        buttonText : 'Press me'
      }
  ]
};

You can pass Actions as a json array. Each object in the array has these params:

urlstring required

A valid url, eg https://stripe.com, http://server.io, etc.

buttonTextstring required

Set the text of the button, eg: Send email to customer, Activate user, Open in stripe, etc.

keystring required

A unique string to identify the action. Use this on your server to differentiate between different actions. For actions marked as external, no key is needed.

externalboolean

If set, opens the url in a external tab. Show a link icon in the button and behaves like a anchor tag basically.

expireInnumber

Action cannot be run after in ‘expireIn’ minutes. Defaults to 10080(7 days). Max value cannot be more than 43200. We recommend this value to be as small as reasonably possible.

metastring/json

Defaults to null. This can be a string, or a object. This will be passed to the server when this action is triggered.

const e = {
  name: "some event",
  avatar: "🤖",
  type : "rows",
  actions : [
    {
      url : 'https://yourserver.com/api/someroute',
      buttonText : 'Press me',
      key : "press_me",
      external : false,
      expireIn : 10080,
      meta : {
        name : "Shash",
        id : 1,
      }
    },
  ]
};

How do actions work?

When pressed, our server will send a POST request to the url specified. It will wait for 10 seconds and give up after that. If the server sends back a 200 or a 201 response status, the actions is marked as complete.

// Sample nodejs/fastify code to catch actions
const Fastify = require('fastify');
const fastify = Fastify();

fastify.register(require('fastify-formbody'));

fastify.post('/ops/action', async (request, reply) => {
  try {
    // Access the parsed body
    const { actionType, data } = request.body;

    // Your logic here
    console.log('Received action:', actionType);
    console.log('Data:', data);

    // Respond to the client
    return { status: 'success', received: { actionType, data } };
  } catch (error) {
    // Handle any errors
    console.error('Error processing request:', error);
    return reply.status(500).send({ status: 'error', message: 'Internal Server Error' });
  }
});

// Start the server
const start = async () => {
  try {
    await fastify.listen(3000);
    console.log('Server listening on http://localhost:3000');
  } catch (err) {
    console.error(err);
    process.exit(1);
  }
};

start();

Actions are great for triggering atomic events. For instance, you can use actions to ban users, or delete a user record. There are multiple safeguards in place to make sure you don’t trigger atomic actions accidently.

Here’s a quick setup for banning users.

const e = {
  name: "some event",
  avatar: "🤖",
  type : "rows",
  actions : [
    {
      url : 'https://yourserver.com/api/someroute',
      buttonText : 'Ban user',
      key : 'ban_user',
      expireIn : 120
    },
  ]
};

Note the really small expireIn time. This will ensure we cannot run our trigger after 2 hours from now(where it won’t be effective).

Structured EventsContexts

Operational

Event tracker for your product.

PrivacyTerms
About the product
  • Use cases
  • Playground
  • API
  • Pitch
  • Wordpress plugin
  • Bubble plugin
Related to the product
  • VS Logsnag
  • Open Source
  • Articles
Useful articles for your business
  • Force post: The Payment Hack that lets Merchants charge you without approval
  • 6 Best practices for early stage B2B SaaS customer support
  • Setup event notifications for your SaaS
  • How to get high quality users for your B2B SaaS business?