In order to guarantee a uniform user experiences, we have set up a number of best practices
Include a readme file for developers to learn about requirements for Secrets and the exposed functionality.
Unless you return a Promise with the Input object, the Flow will stop. Always return it (unless you'd like to throw an error, see below).
Always test if all necessary input parameters are present.
If your modules requires authentication against a third party service, you should use Cognigy Secrets for that purpose. Secrets are defined in the UI by an administrator and can be passed into the Node as a Node Argument.
At the start of your function, check if the secret contains the required keys and if not, return a rejected Promise, which will abort the Flow and show an error in the Cognigy UI.
Try to limit the result size to what is necessary! For example if an API returns all versions of a property, go through them and remove all properties that are not the newest.
Results can be either written to the Input or the Context objects. We recommend to make this configurable through a Node Argument.
- Create a Node Argument
writeToContext
of typeboolean
- If this is false, write the result of your function to the Input object (input.input)
- If this is true, retrieve the Context (
input.context.getFullContext()
) and store the result into the Context
Errors can be handled in two ways:
- Returning a rejected Promise will abort the Flow and show an error in the UI. Note that non-UI users (e.g. on Facebook or Alexa) won't see any output!
- Errors can be written into the results for the Node, enabling the Flow to handle them
As best practice, we recommend the following:
- Always have a Node Argument
stopOnError
of typeboolean
- If the argument is false, write the error into the result object and return a resolved Promise
- If the argument is true, return a rejected Promise with the error as the argument
Make sure to test against the following scenarios:
- Works as intended
- Secret is incorrect or missing key - is it handled?
- Service not available - is it handled?
If you face issues when uploading the module, check below for possible resolutions.
Failed to store custom module information in database.
This error can happen if the descriptors (the comments of a custom module function) are incorrectly formatted. One common issue is the use of the incorrect single quotes. Argument names have to be encircled in ` rather than '.