Using Anypoint Code Builder to Configure Einstein AI Connector 1.2 | MuleSoft Documentation
# Using Anypoint Code Builder to Configure Einstein AI Connector 1.2
**Open Beta Release** : The **cloud IDE is in open beta**. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.
To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes.
## Before You Begin
Before creating an integration project, you must:
  * Set up and access the Anypoint Code Builder web or desktop IDE
  * Have credentials to access the connector’s API
  * Ensure that the Visual Studio Code Extension Pack for Java is installed.


To use this connector, you must be familiar with:
  * The connector’s API
  * Anypoint Connectors
  * Mule runtime engine (Mule)


## Create a New Integration Project
To create a new integration project:
  1. In the activity bar of the IDE, click the (**Anypoint Code Builder**) icon.
  2. From **Quick Actions** , click **Develop an Integration** :
  3. Complete the following in the **Develop an Integration** form:
Attribute | Value  
---|---  
**Project Name** |  Unique name for your project. This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is `salesforce-integration`.  
**Project Location** |  Your home directory or another directory you create. Click **Browse** to select a different directory for the integration project. Don’t create the project within another project directory. See Adding Folders to Your Home Directory.  
  4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card.
  5. Select the **Mule runtime** and **Java Version** for your app.
  6. Click **Create Project**.


## Add Components to Your Project
Add components to your integration project to build a flow:
  1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`.
  2. Select **Build a Flow** from the start card to create an empty flow:
  3. Change the name of the flow:
    1. Click **Flow**.
    2. Click the edit icon.
    3. Enter the flow name, and click the checkmark.
    4. In the canvas UI, click the (**Add component**) icon.
    5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results:
The configuration XML file now includes the XML for the HTTP Listener into the `<flow/>` element, for example:
```
<flow name="getFlights" >
 <http:listener path="" config-ref="" doc:name="Listener" doc:id="ojzfry" />
</flow>
```



## Configure the Trigger For the Flow
A trigger (source) starts the flow when specified conditions are met. If a connector has its own associated sources, you can use a connector-specific trigger to initiate the flow. Each connector trigger has a unique configuration.
You can configure the following sources for this connector:
  * **HTTP > Listener**
Initiates a flow each time it receives a request on the configured host and port
  * **Scheduler**
Initiates a flow when a time-based condition is met


For example, to configure an HTTP Listener trigger, follow these steps:
  1. Click the **Listener** component on the canvas UI.
  2. (Optional) Click the edit icon to change the name of the **Listener** component.
  3. (Optional) If you created a configuration file for the connector, select it.
  4. In the **General** tab, in the **Path** field, enter the relative path for the path set in the HTTP configuration element. See Configure Paths.
  5. Select the **Advanced** tab to configure the following attributes:
Attribute | Description | Required  
---|---|---  
Allowed methods | To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, `GET, POST`, as a comma-separated list.  
Response streaming mode | Whether to use streaming when the response is sent.  
Output MIME type | MIME type of the payload that this component outputs.  
Parameters | Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.  
Output encoding | Encoding of the payload that this component outputs.  
Streaming Strategy | Configures the way data streams are consumed in Mule apps.  
Primary node only | Select this option to execute the **Listener** trigger on the primary node only when running in a cluster.  
Redelivery policy | Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.  
Reconnection strategy | When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation.  
Response | See HTTP Response Attributes.  
Error Response | HTTP error response returns a status code for the error.  
Body of the error message.  
Headers to include in the error message.  
Status code | Status code of the error response, for example, `500`.  
Reason phrase | Reason for the error, for example, `Gateway Timeout` or `Internal Server Error`.  


## Add the Connector to Your Integration Project
  1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`.
  2. Click the (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically.
  3. Add the connector the same way you added other components from the canvas UI:
    1. In the canvas UI, click the (**Add component**) icon.
    2. In the **Add Component** panel, click **Connectors**.
  4. Click the (**Search in Exchange**) toggle:
  5. Enter `einstein ai` in the search box.
  6. Select the connector to add it to your project.


Adding a connector to an integration project doesn’t make that connector available to other projects in your Anypoint Code Builder workspace.
## Add a Global Configuration
  1. In the configuration XML, place your cursor before the `<flow/>` element and type `einstein-ai`.
Ensure that the cursor is not inside the `<flow/>` element.
  2. Select the `ms-einstein-ai:config` snippet:
The snippet adds the following code:
```
<ms-einstein-ai:config llmType="#[]" configType="#[]" filePath="#[]" modelName="#[]" name="name" />
```

  3. Add the attributes to complete the configuration, for example:
```
<ms-einstein-ai:config name="Einstein_AI_Config1" doc:name="Einstein AI Config" doc:id="96f110e3-f17c-4405-8911-80345985da12" >
	<ms-einstein-ai:oauth-client-credentials-connection >
			<ms-einstein-ai:oauth-client-credentials clientId="myclientid" clientSecret="myclientsecret" />
	</ms-einstein-ai:oauth-client-credentials-connection>
</ms-einstein-ai:config>
```

This example shows a flow named "Define_Prompt" with two global elements defined (`http:listener-config` and `ms-einstein-ai:config`):
```
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="0868b5a9-90e8-4470-a255-8b9e8e3938a7" >
	<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<ms-einstein-ai:config name="Einstein_AI_Config" doc:name="Einstein AI Config" doc:id="a68f8f2c-a560-4d8e-9ebe-98a7d8d716cd" >
	<ms-einstein-ai:oauth-client-credentials-connection >
			<ms-einstein-ai:oauth-client-credentials clientId="myclientid" clientSecret="myclientsecret" />
	</ms-einstein-ai:oauth-client-credentials-connection>
</ms-einstein-ai:config>
<flow name="Define_Prompt">
```
This example shows a flow named "Define_Prompt" with two global elements defined (`http:listener-config` and `ms-einstein-ai:config`):
```
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="0868b5a9-90e8-4470-a255-8b9e8e3938a7" >
	<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<ms-einstein-ai:config name="Einstein_AI_Config" doc:name="Einstein AI Config" doc:id="a68f8f2c-a560-4d8e-9ebe-98a7d8d716cd" >
	<ms-einstein-ai:oauth-client-credentials-connection >
			<ms-einstein-ai:oauth-client-credentials clientId="myclientid" clientSecret="myclientsecret" />
	</ms-einstein-ai:oauth-client-credentials-connection>
</ms-einstein-ai:config>
<flow name="Define_Prompt">
```



## Example Customer Feedback Flow
This example flow is designed to handle customer feedback analysis and responses using the Einstein AI service.
In the first route of the scatter-gather component, the flow defines a prompt template for an agent to analyze customer feedback provided in a dataset. If the feedback is negative, the agent is instructed to open a service case and apologize to the customer.
In the second route of the scatter-gather component, the flow defines a chat answer prompt for interacting with the Einstein AI service.
## Configure Additional Connector Fields
After you configure a global element for the connector, configure the other required fields. The required fields vary depending on which connector actions you use.
For more information about configuring Einstein AI Connector actions, see Einstein AI Connector - Additional Configuration Information.
## See Also
  * Introduction to Anypoint Connectors
  * Einstein AI Connector Reference
  * Einstein AI - Additional Configuration Information
  * MuleSoft Help Center