Skip to main content

Raise Event Node

Raise Event Node Screenshot

Overview

The Raise Event Node allows you to trigger an event from within your graph. This event can be listened for by the host project or by a Wait For Event Node within the same graph. This can be useful for triggering actions in your host application based on the state of your graph, or for synchronizing different parts of your graph.

The node requires an event name and optionally an event data. The event name is used to identify the event when it is raised, and the event data is any additional information that you want to associate with the event.

Toast

In the Rivet application, there is a special event named toast which can show a toast message. The toast event accepts a string as its data, which is used as the message of the toast.

Raise Event Node Toast Example

Inputs

TitleData TypeDescriptionDefault ValueNotes
Event NamestringThe name of the event to raise. This input is only available if Use Event Name Input is enabled.(required)The input will be coerced into a string if it is not a string.
DataanyThe data to associate with the event.(empty)The input will be coerced into the appropriate data type based on the value of the Data.

Example 1: Raise an event with data

  1. Create a Text Node and set the text to Hello, world!.
  2. Create a Raise Event Node and leave the Event Name as toast.
  3. Connect the Text Node to the Data input of the Raise Event Node.
  4. Run the graph. The Result output of the Raise Event Node should be Hello, world!, and a toast message should appear in the Rivet application.

Raise Event Node Example 1

Example 2: Wait for an Chat call to finish before continuing another part of a graph

  1. Create a Chat Node and give it a prompt using a Text Node such as "What is your name?".
  2. Create a Raise Event Node, set the Event Name to chat, and connect the Response output of the Chat Node to the Data input of the Raise Event Node.
  3. In a separate part of the graph, add a Wait For Event Node and set the Event Name to chat.
  4. Run the graph. Notice that the Wait For Event Node will not continue until the Chat Node has finished.

Raise Event Node Example 2

Error Handling

The Raise Event Node will error if the Event Name is not provided.

FAQ

Q: How can I listen for the event that was raised?

A: You can listen for the event in your host application by using the onUserEvent property of RunGraphOptions. You can also listen for the event within the same graph by using a Wait For Event Node.

Q: Can I pass data with the event?

A: Yes, you can pass data with the event by providing a value to the Data input. The data can be of any data type.

Q: What happens if I raise an event that no one is listening for?

A: If you raise an event that no one is listening for, nothing will happen. The event will be raised and then immediately discarded.

Q: How is raising event different from an External Call Node?

A: The External Call Node will wait for the external call to complete before continuing, whereas the Raise Event Node will continue immediately after raising the event.

See Also