Cloud code

Execute custom code that is hosted on the flow.ai platform. Cloud code is JavaScript that runs in a sandboxed environment and allows you to easily customise and extend Flow.ai’s capabilities.

Limited execution time

When using cloud code the code execution or a call to a service must be done within 10 seconds.

Quick examples

Send text

(function(payload) {
  const text = new Text(`This a reply text from your bot.`)
  const message = new Message(`This a reply text from your bot as a fallback text.`)

  message.addResponse(text)

  return message
})

Send text with quick replies

(function(payload) {
  const text = new Text(`This a reply text from your bot.`)
  text.addQuickReply(new QuickReply({ label: 'Again', value: 'Get started' }))
  const message = new Message(`This a reply text from your bot as a fallback text.`)

  message.addResponse(text)

  return message
})

Sending an email

(function(payload) {
  toolbelt.email({
    to: '[email protected]',
    subject: 'This is the subject of you email.',
    message: 'Compose the body of your email here.'
  })
})

Trigger a flow

Within Code you can choose to either reply directly with messages, or trigger different flows.

(function(payload) {
  trigger('EVENT')
})