Widgets/Consumer
Output Widget
Output Widget
A "Consumer" type widget. Output Widget is a specialized widget designed to complete the input-output cycle for recipes exported to Kemu-Edge. It works in conjunction with Input Widgets to enable the sendToInputWidgetAndWaitForOutput functionality, allowing external callers to retrieve processed values from recipes.
Purpose
When recipes are exported to Kemu-Edge, external systems need a way to:
- Send data to an Input Widget
- Wait for the recipe to process that data
- Retrieve the final result
The Output Widget serves as the endpoint that completes this cycle by resolving the input event with the processed result.
Inputs
- event (DataType: Anything) The processed data that should be returned to the caller. This port receives the final result from your recipe's processing chain.
Outputs
The Output Widget has no output ports. It serves as the final endpoint in the recipe execution chain.
How It Works
- Input Registration: When an Input Widget receives data and
waitForOutputis enabled, it registers the event with a unique key - Processing Chain: The data flows through your recipe's widgets (Script, Logic, etc.)
- Output Resolution: The Output Widget receives the final processed data and resolves the original input event
- Value Return: The caller receives the processed value through the
sendToInputWidgetAndWaitForOutputpromise
Usage Pattern
The typical pattern for Kemu-Edge integration is:
Input Widget → [Your Processing Widgets] → Output Widget
Example Recipe Structure:
- Input Widget: Receives external data (e.g., user input, API request)
- Script Widget: Processes the data (e.g., calculations, transformations)
- Output Widget: Returns the processed result to the caller
Exporting Recipes for Kemu-Edge
Export your recipe as a Node.js application using Kemu-Edge Export to enable external code interaction with the Output Widget.
Export Process:
- Click the Home icon (house) in the Kemu interface
- Select "Kemu Edge Export" from the available options
- Choose export mode:
Javascript Library(recommended for programmatic integration) - Click "Export" and wait for completion

Examples
Double Input Value and Return via Output Widget
Processes an input number and returns the computed result through the Output Widget.
Drag the example onto the workspace to explore and experiment!
In this example:
- The Input Widget receives
5and sends it from the "output" port to the Script Widget "input" port - The Script Widget doubles
5to10and sends it from "result" to the Output Widget "event" port - The Output Widget resolves the original input event and returns
10to the external caller
When called via sendToInputWidgetAndWaitForOutput, the external system would receive 10 as the result.
How to Run This Example
- Export the recipe as "Javascript Library Mode" from Kemu Edge
- Open the exported folder and edit
main.jswith the following code:
import kemuEdge, { DataType } from '@kemu-io/edge-runtime'; console.log('Starting recipe...'); const recipe = await kemuEdge.start(); console.log('Recipe running...'); // Send data and wait for output directly const result = await recipe.sendToInputWidgetAndWaitForOutput('numToDouble', { type: DataType.Number, value: 5 }); console.log('Recipe result:', result);
- Open the terminal in the exported folder and run:
npm install node main.js
- Expected Output:
Starting recipe... Recipe running... Recipe result: 10
Note: If you enabled "Install dependencies" during export, npm install was already executed automatically.
Create Personalized Message and Return via Output Widget
Creates a personalized message with current date/time and returns it through the Output Widget.
Drag the example onto the workspace to explore and experiment!
In this example:
- The Input Widget receives a name string and sends it from the "output" port to the Template String Widget "input" port
- The Template String Widget creates a personalized message using the input name and current date/time variables, then sends it from "text" to the Output Widget "event" port
- The Output Widget resolves the original input event and returns the formatted message to the external caller
When called via sendToInputWidgetAndWaitForOutput, the external system would receive a personalized message with current date and time.
How to Run This Example
- Export the recipe as "Javascript Library Mode" from Kemu Edge
- Open the exported folder and edit
main.jswith the following code:
import kemuEdge, { DataType } from '@kemu-io/edge-runtime'; console.log('Starting recipe...'); const recipe = await kemuEdge.start(); console.log('Recipe running...'); // Send data and wait for output directly const result = await recipe.sendToInputWidgetAndWaitForOutput('userName', { type: DataType.String, value: 'John Doe' }); console.log('Recipe result:', result);
- Open the terminal in the exported folder and run:
npm install node main.js
Note: If you enabled "Install dependencies" during export, npm install was already executed automatically.
- Expected Output:
Starting recipe... Recipe running... Recipe result: Hello, John Doe! You have a meeting scheduled on: 📅 Monday, 1/27/2025 🕰 14:30 Wishing you a productive day!
Integration with Kemu-Edge
The Output Widget is essential for Kemu-Edge integration because it:
- Completes the Promise Chain: Resolves the promise returned by
sendToInputWidgetAndWaitForOutput - Enables Synchronous Communication: Allows external systems to wait for recipe completion
- Returns Processed Results: Provides the final output of your recipe's processing logic
Without an Output Widget, recipes exported to Kemu-Edge cannot return values to external callers.
Best Practices
- Always Include an Output Widget: For recipes intended for Kemu-Edge export, always end your processing chain with an Output Widget
- Single Output Path: Typically, you should have one Output Widget per recipe to avoid confusion
- Data Type Consistency: Ensure the data type sent to the Output Widget matches what external systems expect
- Error Handling: Consider how errors in your processing chain should be handled and whether they should reach the Output Widget
📌 Notes
- The Output Widget is primarily designed for Kemu-Edge integration and may not be necessary for regular recipe development
- It works internally with the Input Event Manager to track and resolve input events
- The widget automatically handles event context resolution to ensure the correct result is returned to the original caller
Glossary
-
Kemu Edge Export
A feature that converts Kemu recipes into standalone Node.js applications that run independently of the Kemu platform. This enables independent deployment on any server, cloud platform, or local machine, system integration into existing applications, and scalable architecture without platform dependencies.