Skip to main content
In this tutorial, we’ll walk through building a command line chat experience using the Inworld Node.js Agent Runtime SDK. We will create a graph using both custom and built-in nodes which will be executed on each user input.

Prerequisites

Set Up the Application

We’ll start by creating a new directory, entering it, and initializing it using npm.
bash
Next, we’ll install the Inworld Node.js Agent Runtime SDK as well as other necessary dependencies.
bash
Create a .env file in your project root with the following content:
.env
Replace your_api_key_here with your actual API key from the Inworld Portal.

Create Basic Chat

We’ll create a new file called chat.ts in your project root and add the following code:
chat.ts
Run the script from your project root:
bash
Congratulations! You’ve just created an interactive chat experience with a very thoughtful assistant. But of course we want to make the assistant smarter. So let’s create a simple graph to integrate an LLM call.

Add LLM Call

Create a new file called llm-chat.ts in your project root with the following code:
llm-chat.ts
Run the LLM-powered chat from your project root:
bash
Now our assistant is a lot smarter! But our prompting could definitely be improved. Let’s add a custom node to our graph which will take the messages as an input, render a prompt from a Jinja template, and output the chat messages required by our LLM.

Add Jinja Templating

Create a new file called jinja-templating.ts in your project root with the following code:
jinja-templating.ts
Run the advanced templating example from your project root:
bash
You now have three working examples:
  1. chat.ts - Basic interactive chat interface
  2. llm-chat.ts - AI-powered chat using Inworld’s LLM
  3. jinja-templating.ts - Advanced chat with custom prompting and graph nodes
Each file demonstrates different aspects of the Inworld Agent Runtime SDK, from basic graph building to custom node creation and advanced templating.