Skip to main content

REFERENCE

Developer Reference

Authentication, APIs, SDKs, Flow Agent processors and parameter resolution, in full.

Resolving values

In an Asgard workflow, a setting's value can be resolved three ways: Literal, Expression and Template.

  1. The three ways​

    Literal​

    Fixed content.

    Example:

    Welcome to our service!

    Expression​

    A JavaScript expression, for computation and logic.

    Examples:

    // read a variable directly
    prevMessage

    // read with a boolean expression
    userName || 'guest'

    // call a built-in function and use its return value
    history(0, -1)

    // call a built-in function and use its return value
    urlEncode(searchKeyword)

    Template​

    Rendered with Handlebars syntax.

    Example:

    {{#each prevBlobs}}
    File
    {{@index}}:
    {{fileName}}
    {{#if (eq fileType 'IMAGE')}}
    Image file: {{mime}}
    {{/if}}
    {{/each}}
  2. What is built in​

    Built-in variables​

    • Conversation: prevMessage, prevBlobs, prevPayload, prevError
    • Channel: customChannelId, customMessageId

    See Expression variables for the details.

    Built-in functions​

    Eight functions are provided:

    • Conversation history: history(), historySize()
    • Data handling: urlEncode(), vecToStr(), xpathExtract()
    • Date and time: isoNow(), isoToday()

    See Expression built-in functions for the details.

  3. Examples​

    Expression mode​

    // using a variable
    prevMessage || 'no message'

    // a conditional
    prevError ? `Error: ${prevError}` : 'processed normally'

    // calling a function
    `Conversation length: ${historySize()} messages`

    Template mode​

    {{#if prevMessage}}
    You just said: {{prevMessage}}
    {{else}}
    Welcome, let's begin!
    {{/if}}

    The time now: {{{isoNow 'Asia/Taipei'}}}

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us