Introduction to Inline Agents¶
In this tutorial, you'll learn how to connect an AI agent to a GraphQL service, enabling the agent to be invoked directly within a GraphQL resolver. This demonstrates the use of an inline agent—a powerful capability in the WSO2 Integrator: BI.
Unlike chat agents, which are exposed as REST APIs for external interaction, inline agents are not tied to an API endpoint. Instead, they can be invoked programmatically from anywhere within your integration logic, just like a regular function call.
In this example, we'll define a GraphQL schema with a query that invokes the inline agent to generate dynamic responses based on input parameters. The agent runs within the resolver logic and returns results directly as part of the GraphQL response.
Step 1: Create a new integration project¶
- Click on the WSO2 Integrator: BI icon in the sidebar.
- Click on the Create New Integration button.
- Enter the project name as
GraphqlService. - Select the project directory by clicking on the Select Path button.
-
Click the Create New Integration button to generate the integration project.
Step 2: Create a GraphQL service¶
- In WSO2 Integrator: BI design view, click Add Artifact.
- Select GraphQL Service under the Integration as API artifacts.
-
Keep the default Base path and Port configurations, and click Create.
Step 3: Create a GraphQL resolver¶
- Click the + Create Operations button in the GraphQL design view.
- In the side panel, click the + button in the Mutation section to add a mutation operation.
- Provide
taskas the value for the Field name. - Click the Add Argument button to add a GraphQL input
- Provide
queryfor the Argument name. - Provide
stringfor the Argument type. - Click Add to save the argument.
- Provide
-
Provide
string|errorfor the Field type, as this will be used as the return type of the resolver.
Step 4: Implement the resolving logic with an inline agent¶
- Click the created
taskoperation in the side panel to navigate to the resolver editor view. - Click the + button in the flow to open the side panel.
- Click Agent under the AI section, which will navigate you to the agent creation panel.
- Update the Role and Instructions to configure the agent’s behavior.
- Switch from
Textmode toExpressionmode in the Query field and provide thequeryparameter as the input. This will serve as the command that the agent will execute. - Update Result to
response. This is where the agent's output will be stored. -
Click Save.
-
Next, configure the agent’s memory, model, and tools. For guidance, refer to the Chat Agent configuration steps and the Personal Assistant setup guide to make the agent function as a personal assistant.
- After configuring the agent, click the + button on the flow and select Return under Control from the side panel.
-
For the Expression, provide the
responsevariable as the input.
At this point, we've created a GraphQL resolver that takes a user-provided query as input, passes it to an inline agent for processing, and returns the agent’s response as the result of the resolver.
Note
You must implement a query operation to have a valid GraphQL service. Similar to creating the task operation in Step 3, add an operation named greet by pressing the + button in the Query section, without any input parameters. For the implementation, you can simply return a string literal saying "welcome".





