Home Articles Pitch Api

Contents

Start hereAPI DocsIntroductionSend your first eventEvent parametersStructured EventsActionsContextsError handlingManualIntroductionBasicsConventionsSetupTest modeNotificationsPWA

Sending structured events

You can pass various data formats and structured form objects to render better events.

Here’s an example for text event.

🤖
some event

12:00 am

This is some info about the event
const e = {
  name: "some event",
  avatar: "🤖",
  content : 'This is some info about the event'
};
Copy

Note that you don’t explicitely need to pass type: ‘text’ since type is assumed to be ‘text’ by default.

Here’s another example with type json.

const e = {
  name: "some event",
  avatar: "🤖",
  type : 'json',
  content : {
    form_data_1 : 'something',
    form_data_2 : 'something else',
    obj : {
      nestedField1 : 1,
      nestedField2 : 'hmm'
    }
  }
};
Copy

Here’s another example with type image.

🤖
some event

12:00 am

const e = {
  name: "some event",
  avatar: "🤖",
  type : "image",
    content : `https://images.unsplash.com/photo-1724026403614-f5461d17c6cc?q=80&w=3200&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D`
};
Copy

You can also stack different formats together. Use type ‘rows’ for this. Here’s an example.

🤖
some event

12:00 am

Some
text
Here
const e = {
  name: "some event",
  avatar: "🤖",
  type : "rows",
  content : [
    {
      type : 'text',
      content : 'Some'
    },
    {
      type : 'text',
      content : 'text'
    },
    {
      type : 'text',
      content : 'Here'
    }
  ]
};
Copy

Type rows will take content as an array. These are all the options for each object inside the array.

typestring

If left blank, defaults to ‘text’. Controls how content field is rendered. Options are ‘text’, ‘json’, ‘image’. Note that you cannot have rows inside rows. Inception isn’t possible currently.

contentstring/json

Mixed content type, can be a string or JSON depending on what type is set.

labelstring

If set, shows a small label above the content.

const e = {
  name: "some event",
  avatar: "🤖",
  type : "rows",
  content : [
    {
      content : 'Text content, type is assumed to be text by default'
    },
    {
      label : 'label',
      type : 'text',
      content : 'Text content with label'
    },
    {
      type : 'image',
      label : 'image',
      content : `https://images.unsplash.com/photo-1724026403614-f5461d17c6cc?q=80&w=3200&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D`
    }
  ]
};
Copy

This will render the following event:

🤖
some event

12:00 am

Text content, type is assumed to be text by default
Text content with label

Here’s a much better example of a real life scenario.

const e = {
  name: "some event",
  avatar: "🤖",
  type : "rows",
  content : [
    {
      label : 'Name',
      content : 'Shash'
    },
    {
      label : 'Email',
      content : 'shash@operational.co'
    },
    {
      label : 'IP',
      content : '173.69.420.422'
    },
    {
      label : 'form',
      type : 'json',
      content : {
        works_in : 'performance marketing',
        found_us : 'google'
      }
    }
  ]
};
Copy
Event parametersActions