cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Overview of Code Actions

Overview of Code Actions

Execute custom code that is hosted on the Flow platform. Code actions are JavaScript that runs in a sandboxed environment and allows you to easily customize and extend Flow 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

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

  message.addResponse(text)

  return message
}

Send text with quick replies

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

  message.addResponse(text)

  return message
}

Sending an email

async payload => {
  toolbelt.email({
    to: 'name@domain.com',
    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.

async payload => {
  trigger('EVENT')
}
 

 Read more on Code Actions:

 

Labels (1)

Overview of Code Actions

Execute custom code that is hosted on the Flow platform. Code actions are JavaScript that runs in a sandboxed environment and allows you to easily customize and extend Flow 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

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

  message.addResponse(text)

  return message
}

Send text with quick replies

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

  message.addResponse(text)

  return message
}

Sending an email

async payload => {
  toolbelt.email({
    to: 'name@domain.com',
    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.

async payload => {
  trigger('EVENT')
}
 

 Read more on Code Actions:

 

Labels (1)

Overview of Code Actions

Execute custom code that is hosted on the Flow platform. Code actions are JavaScript that runs in a sandboxed environment and allows you to easily customize and extend Flow 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

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

  message.addResponse(text)

  return message
}

Send text with quick replies

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

  message.addResponse(text)

  return message
}

Sending an email

async payload => {
  toolbelt.email({
    to: 'name@domain.com',
    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.

async payload => {
  trigger('EVENT')
}
 

 Read more on Code Actions:

 

Labels (1)
Version history
Last update:
‎06-17-2021 05:20 AM
Updated by:
Contributors