Function

On This Page

    The function module is where the app's behavior is defined. Other modules specify the function module that defines the actions to take.

    Properties

    PropertyTypeRequiredDescription
    keystringYes

    A key for the module, which other modules can refer to. Must be unique within the manifest and have a maximum of 23 characters.

    Regex: ^[a-zA-Z0-9_-]+$

    handlerstringYes

    A pointer to the function responsible for handling invocations.

    Expected format: file.function

    For example, jira.issueCreationTrigger calls the issueCreationTrigger function defined in jira.js in the app's src directory.

    Regex: ^[a-zA-Z0-9_-]+$

    providersProviders

    A list of the providers required by the function.

    timeoutSecondsintegerNo

    A maximum timeout, in seconds, for a function that is always invoked as a consumer of an async event. If this parameter is not specified for a function that is used as an async event consumer, the function will timeout after the default 55 seconds.

    This parameter has no effect on functions that are not used as async event consumers.

    Range: 1-900

    Example

    1
    2
    modules:
      function:
        - key: main
          handler: index.run
    

    Provider reference

    1
    2
    export interface ProviderReference {
      provider: string;
      requiredScopes?: string[];
    }
    
    PropertyTypeRequiredDescription
    authList<ProviderReference|string>Yes

    A list of keys or objects referencing authentication providers.

    Using requiredScopes in the reference object also allows you to specify scopes that must be granted by the external provider before invocation. If any of these specified scopes are not granted, the request will trigger the OAuth 2.0 consent flow, and the actual function code will not be invoked. This provides a better performance over using requestCredentials in the code.

    Example

    1
    2
    function:
      - key: google-macro
        handler: index.google_macro
        providers:
          auth:
            - provider: google
              requiredScopes:
                - 'https://www.googleapis.com/auth/userinfo.profile'
                - 'https://www.googleapis.com/auth/userinfo.email'
      - key: dropbox-macro
        handler: index.dropbox_macro
        providers:
          auth:
            - dropbox
    

    Rate this page: