message
), no output ports and its purpose is to send an SMS using the Twilio API.context
. The context contains all the information you need to process your messages and send new messages to the output ports.receive()
)content
property that contains the actual data of the message after all variables have been replaced. For example:message
was defined in the Inspector using variables:context.messages
object contains the result of replacing variables with actual data that was sent through the output port of the connected component, i.e.context.messages.myInputPort.correlationId
property.correlationId
is a "session ID" that associates all the messages in one pass through the flow. Every time a trigger component sends a message to the flow (e.g. webhook, timer, ...) and the message does not have a correlation ID yet, the Appmixer engine assigns a new correlation ID to the message. This correlation ID is then copied to all the messages that were generated as a reaction to the original trigger message.receive()
, tick()
or start()
methods or awaited.auth
object in your Authentication module (auth.js
) for your service. For example, if our authentication module for our service (auth.js
) looks like this:context.auth.accountSID
and context.auth.authenticationToken
in the component virtual methods:context.auth.apiKey
in the component and insert the apiKey
into Backoffice:context.auth
or context.config
objects. context.config
is just an alias to the original context.auth
. properties
object from the component manifest file. For example, if our component defines the following properties in the manifest file:context.properties.fromNumber
will contain the value the user entered in the Designer UI Inspector:state: { peristent: true }
property in your component manifest. context.state
is a simple object with keys mapped to values that are persistently stored in DB. This object is loaded on-demand in each receive()
call. It is not recommended to store large amounts of data here. Example:context.state
is especially useful for trigger-type of components when polling an API for changes to store the ID of the latest processed item from the API.context.state
object should not be used to store large amounts of data. The state is loaded with each received message on a component input port. The maximum limit is 16MB but storing such large objects will slow down the processing of the component input messages.context.state
, but there are cases when a component needs to reload the state from the DB.context.state
for details. The function returns a promise that resolves if storing of the state was successful and rejects otherwise.key
to hold the value
. key
must be a string. value
can be any JSON object.key
.key
.key
to hold the value
. key
must be a string. value
can be anything that can be stored in Mongo DB.key
.key
.value
into a Set stored under key
.value
from Set stored under key
. context.saveFile(name, mimeType, buffer)
.fileId
can be either Mongo ID or UUID.fileId
can be either Mongo ID or UUID. The function returns a promise that when resolved, gives you the file data as a Buffer.context.loadFile(fileId)
. fileId
must be Mongo ID.context.loadFile(fileId)
. This method is backward compatible, sofileId
can be either be Mongo ID or UUID.fileId
can be either Mongo ID or UUID.receive()
method of your component is called by the engine with context.messages.webhook
object set and context.messages.webhook.content.data
contains the actual data sent to the webhook URL:context.getWebhookUrl()
is only available if you set webhook: true
in your component manifest file (component.json). This tells the engine that this is a "webhook"-type of component.context.messages.webhook
object contains the following properties:content.method
content.hostname
content.headers
content.query
content.data
correlationId
context.getWebhookUrl()
in the receive()
method in a reaction to an input message that arrived on an input port of the webhook component, the correlationId
will be part of the returned webhook URL. This allows you to later associate the input message with the HTTP call to the webhook. A common pattern is to store the input message in the context.state
object and later use the context.messages.webhook.correlationId
to retrieve it back. For example, if you have an input port named myInPort
, you can get the correlationId
of the input message that just arrived by accessing the context.messages.myInPort.correlationId.
webhook: true
in your component.json file), context.getWebhookURL()
becomes available to you inside your component virtual methods. You can use this URL to send HTTP POST requests. context.messages.webhook.content.data
contains the body of your HTTP POST call. In order to send a response to this HTTP call, you can use the context.response()
method. See context.getWebhookUrl()
for details and examples.messageContent
in the receive()
method in the special context.messages.timeout.content
object. delay
is the time, in milliseconds, the timer should wait before sending the messageContent
to the component itself. Note that this is especially useful for any kind of scheduling components. Note that the context.setTimeout()
function works in a cluster environment as opposed to using the global setTimeout()
JavaScript function. For example, a component that just "slows down" incoming messages before sending them to its output port, waiting e.g. 5 minutes, can look like this:context.messages.timeout.correlationId
property.context.flowDescriptor[context.componentId]
. Note that this is normally not necessary since you can access the properties of the components by context.properties
and the current input message by context.messages.myInPort.content
but can be useful in some advanced scenarios.loadVariables()
returns a promise that resolves to an array that looks like this:receive
call can be executed at a time) or using this lock. This method returns the lock
instance. Don't forget to call lock.unlock()
when you're done. Otherwise, the lock will be released after TTL.lockName
string will be prefixed with vendor.service:
. If a component type is appmixer.google.gmail.NewEmail
, then the lockName will be prefixed with appmixer.google:
. This allows you to create a lock that is shared among all components within a service and prevents possible collisions between components from different vendors or services.ttl
, number, 20000 by default (ms)retryDelay
, number, 200 by default (ms)maxRetryCount
, number, 30 by defaultreceive
call again in a minute. There is an exponential backoff strategy, so the next attempt will happen in a minute and a half and so on. In total, Appmixer will try to process that message 30 times before it is saved into unprocessedMessages
collection. Every unsuccessful attempt will be logged and visible in Insights.tick
function throws an exception, such exception is logged (and visible in Insights) and that is it. Appmixer will trigger this function again in the future.start
function. Such error will be logged and visible in Insights.stop
function. Such errors will be logged and visible in Insights.