How to Send Variable Values from Actions to Forms and Back to Actions

Last Updated: Dec 17, 2024

Overview

This article describes how to pipe variables created in the Actions to the Form and Back from the Form to the Action using the onContinuePostLogin method.

Applies To

  • Forms
  • Actions

Solution

Values can be passed from Actions to Forms using:

api.prompt.render(':form_id', {
    fields: {
      first_name: 'Foo',
    }
});

The variables are accessible in the onContinuePostLogin method of the Action after the Forms execution completes.

exports.onContinuePostLogin = async (event, api) => {
   console.log(event.prompt?.vars?.first_name);
};

Related References