Multiagent bot in J‑Graph
To get started with AI agents in J‑Graph:
- Set up connection to Caila.
- Add an AI agent block.
This example shows a script in J‑Graph for a bot that helps customers of a streaming service. The script has two states with AI agents:
- The first agent recommends a movie for the user.
- The second agent helps choose a subscription.
Add only one AI agent block to a state. If several such blocks are added to the state, agent errors might occur.
-
At the beginning of the dialog, the bot immediately transitions to the
Moviestate. In this state, therecommend_movieagent communicates with the user.Parameters of the
recommend_movieAI agent-
General settings:
- Agent ID:
recommend_movie. - LLM:
gpt-4o. - Agent role:
Streaming service employee. - Agent goal:
Help the user choose a movie. - Instructions:
Ask questions about the user’s preferences to choose a movie. Once the user picks a movie, ask if they want to subscribe to the service.
- Agent ID:
-
History settings:
- Pass the bot dialog history to the agent: parameter enabled.
- Number of recent messages from the history:
50.
-
Transitions to other states:
- Allow the agent to transfer the dialog to other agents in the script: parameter enabled.
- Next state if the agent achieved the goal:
Feedback.
-
-
The
recommend_movieagent asks the user for their preferences and suggest movies. The agent continues until the user selects a movie. Next, the agent offers to subscribe to the streaming service, as we specified in the instructions. -
If the user wants to subscribe, the
recommend_movieagent transitions the dialog to theSubscriptionstate. This state contains thesubscribeagent.noteThe
recommend_movieagent can transition the dialog to another agent, because therecommend_moviehas the Allow the agent to transfer the dialog to other agents in the script parameter enabled. For this parameter, possible transitions between agents are not displayed on the J‑Graph canvas. -
The
subscribeagent offers various subscription options following the instructions.Parameters of the
subscribeAI agent-
General settings:
- Agent ID:
subscribe. - LLM:
gpt-4o. - Agent role:
Streaming service employee. - Agent goal:
Help the user subscribe. - Instructions:
First offer a yearly subscription. Price for a year: $30. If the user doesn’t want that, offer a monthly subscription. Price for a month: $3. Once the user chooses a subscription, send a link for registration: example.com/year for a yearly subscription or example.com/month for a monthly subscription.
- Agent ID:
-
History settings:
- Pass the bot dialog history to the agent: parameter enabled.
- Number of recent messages from the history:
50.
-
Transitions to other states:
- Allow the agent to transfer the dialog to other agents in the script: parameter enabled.
- Next state if the agent achieved the goal:
Feedback.
noteThe
subscribeagent also has the Allow the agent to transfer the dialog to other agents in the script parameter enabled. If the user asks for a movie recommendation at any point in the dialog, the agent automatically transitions the dialog to theMoviestep. -
-
If the user has no more questions, the current agent transitions the dialog to the
Feedbackstate.