Sending structured events
You can pass various data formats and structured form objects to render better events.
Here’s an example for text event.
const e = {
name: "some event",
avatar: "🤖",
content : 'This is some info about the event'
};
CopyNote 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'
}
}
};
CopyHere’s another example with type image.
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`
};
CopyYou can also stack different formats together. Use type ‘rows’ for this. Here’s an example.
const e = {
name: "some event",
avatar: "🤖",
type : "rows",
content : [
{
type : 'text',
content : 'Some'
},
{
type : 'text',
content : 'text'
},
{
type : 'text',
content : 'Here'
}
]
};
CopyType rows will take content as an array. These are all the options for each object inside the array.
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.
Mixed content type, can be a string or JSON depending on what type is set.
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`
}
]
};
CopyThis will render the following event:
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