When there is a use case to schedule a message to be sent in the future either at a given time or on a regular basis, developers can use the jobScheduler class.

This class has one public method called scheduleMessage({arguments}) that receives the following arguments:

  • toBot: 
  • toUser:
  • messages:
  • jobId:
  • schedule:
  • repeats:
  • client:
  • realTimeMessage:


This parameter is optional and it defaults to the current micro app botId. If the message needs to be addressed to another micro app, the developer must pass the correspondent botId.



This parameter is mandatory and it refers to the userId or userIds to whom this message will be addressed to. The parameter can receive a single string (userId) or an array of strings with multiple userIds.



This parameter can be a single object or an array of objects and it must contain the exact content of the message. For instance, if a micro app is expecting a message like this: 

intentId: 'myIntentName'

This is the exact message that needs to be included in this argument.



This parameter is optional and it is used to identify the jobId in case a jobId needs to be modified. If the same jobId is sent again, the system will modify the instance instead of creating a new one.



This is an optional argument that must contain the epoch time when the message is expected to be sent. If there are repetitions, then it is the time where the first message is going to be sent.



The repeats argument (optional) is an object like follows:

repeats: {
quantity: 10,
unit: 'second',
interval: 30

The example above send the message 10 times every 30 seconds. The units can be second, minute, hour, day, week, and month.



This parameter is optional and it refers to the client where this message must be sent. For instance, if the message must be addressed directly to the mobile apps or web apps.

This message must be used in combination to the next parameter since it will only be used in case the message is realTime.

This parameter can have these two values:

  • botState.MOBILECLIENT()
  • botState.EDGE_WEBCLIENT()


This is an optional boolean parameter. When is set to true (default) the message is sent to the edge to be processed on the edge. If the value is false, the message is sent to the cloud.


Example call

let messages = [
intentId: "myIntentId",
message: "Hello how are you?"

await botState.jobScheduler.scheduleMessage({




Please sign in to leave a comment.