Skip to main content

Multiagent bot in J‑Graph

tip

To get started with AI agents in J‑Graph:

  1. Set up connection to Caila.
  2. 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 uses two AI agents:

  • The first agent recommends a movie for the user.
  • The second agent helps choose a subscription.
Example with two AI agents
  1. At the beginning of the dialog, the bot immediately transitions to the Movie state. In this state, the recommend_movie agent communicates with the user.

    Parameters of the recommend_movie AI 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.
    • 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.
  2. The recommend_movie agent 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.

  3. If the user wants to subscribe, the recommend_movie agent transitions the dialog to the Subscription state. This state contains the subscribe agent.

    note

    The recommend_movie agent can transition the dialog to another agent, because the recommend_movie has 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.

  4. The subscribe agent offers various subscription options following the instructions.

    Parameters of the subscribe AI 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.
    • 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.
    note

    The subscribe agent 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 the Movie step.

  5. If the user has no more questions, the current agent transitions the dialog to the Feedback state.