Untitled

<aside> đźš‚

Purpose: Build a website agent that qualifies leads and logs them into a marketing automation platform

Related Case Study: This tutorial explains how to build the agent exposed on the squadra.ai website and on whatsapp at +33 7 59 68 72 03 Real-world application: Whether you expose your professional services through a website or a public Whatsapp number, you can replicate this Agent to qualify your entrant leads and log them in your marketing tool at any time

Duration: 10 mn from start to finish!

Key tools: API-call functions; Brevo; website embedding

</aside>

Introduction

In this tutorial, we will share step by step how to create an Agent similar to the Agent we use on squadra.ai to qualify leads. This Agent engages in a conversation with visitors, either through the website or on Whatsapp (but it is technically the same agent, deployed through both channels) :

Step 1: Orchestrate your agent… on paper

Building an agent is first and foremost on exercice of rigorously segmenting the different scenarios, triggers and tasks that your agent will be exposed to.

In this case, here’s how we thought about George (that’s how we named her):

Here is the full range of functions we ultimately created for George ; we will dive into the construction of two of these functions in sections 3 and 4.

image.png

Now, let’s start.

Step 2: Create the Agent

First go to app.squadra.ai, section Agent, create and name your agent.

You will land in this interface :

image.png

For more details about parameters, etc, you can go to the Agent section of this documentation. In this tutorial, we will just briefly explain dictate most settings to get you started.

Model: Select GPT-4o mini

Advanced setting: Do not touch!

Main prompt: there are many tutorials out there on how to write a good prompt, but here is the receipe we usually follow:

Step 3: Create an Intent function to answer basic questions

It’s time to create your first function, and it’s the simplest function type: an intent function. Go to Functions, and create a new Function; you can name it “about”.

Note: to create Agents with deep knowledge (for example: an agent that would know the content of the whole Drive of an organisation, or all the legal precedents about GDPR, or the history of the articles in a newspaper), your go-to function would be a Search function, allowing to perform RAG (Retrieval Augmented Generation). Considering we already displayed a Search function in the first tutorial, and considering this agent only needs a few dozen lines of text of information, we decide here to illustrate a case of a simple intent function.

Go to Function > New and select Intent as the function type for your new function.

image.png

Your function type will be fairly easy to setup:

<aside> ✍️

“Information about Squadra, which is both the organization and the platform in which are created AI agents. Information includes the differentiators of the Squadra platform and its pricing.”

</aside>

<aside> ✍️

“Squadra SAS, registered with the Marseille Trade and Companies Register under SIREN number 933 235 087, is a technology company specializing in AI development. Its technological platform enables the creation of AI agents—software components capable of executing workflows (i.e., performing any digital action such as responding to a text message, updating information in a database, or modifying content on a website). These agents can take actions autonomously based on specific sources of information (e.g., interpreting news on a website, updates in a CRM, etc.)

Features The Squadra product includes the Administration platform, the API, as well as a large number of connectors. The Administration Platform a web interface enabling administrators to configure, test, deploy, and monitor advanced agents. Its main sections include…”

</aside>

Step 4: Create an API call function to Brevo

Now, you want the user to gather information from the conversation, and once they have the full relevant information, log a new contact in Brevo.

The first part (gathering the information) happens in the main prompt of the agent (see step 2). You now need to create a new API function. Go to Functions and create the + New button on top of the table. Name your function create_new_lead, and select the type API call.

Step 4.1: Create a new function

As with the previous function, you need to define the Function prompt, telling when it should be triggered. We simply used the prompt:

<aside> ✍️

“Log a new record into the contacts database of marketing platform Brevo.”

</aside>

image.png

Step 4.2: Brevo

The first and fundamental element of Brevo or any other Marketing platform is the database of contacts, and the attributes you can configure. Go to https://app.brevo.com/contact/settings under section Contacts > Settings, and configure an Notes fields, on top of other fields such as email, name, surname, etc, which should already be configured.

Now go to Brevo’s API documentation, and more specifically to the endpoint to create a new contact https://developers.brevo.com/reference/createcontact.

Scroll down to Attributes Objects and add fields which you will want the Agent to log. In this example, I filled an email in the default fields, as well as a note field, and listIds 2 which means the contact will be logged in my list #2 where I log prospects from my website (see the left side of the screenshot). On the right side, Brevo shows you how to create a proper API call to trigger the creation of a new contact with these parameters.

image.png

Here is the CURL request:

curl --request POST \\
     --url <https://api.brevo.com/v3/contacts> \\
     --header 'accept: application/json' \\
     --header 'content-type: application/json' \\
     --data '
{
  "attributes": {
    "Note": "Once upon a time",
    "email": "[email protected]"
  },
  "updateEnabled": false
}
'

Step 4.3: Back to Squadra

Return to your API call function, and copy the relevant information for calling the API, as specified in the Brevo documentation:

image.png

Now go to Development > Environment and create a new variable called brevo_secret. Go to Brevo at https://app.brevo.com/settings/keys/smtp and Generate a new API key. Give it a name such as “squadra_website_agent”, and copy it under the field Value in Squadra.

image.png

Back to your Function configuration. For the function to execute properly, your Agent will need to feed it with the right parameters to be logged into Brevo. These parameters are an email (which the Agent will need to ask the user – look back at the Main prompt for reminders !), and “notes”, in which you want to be able at a glance to understand who was the viistor and what was their business case. Here is what we told our Agent (click + Add parameter and copy the Schema below):

image.png

Now that your function has the right inputs, you need to transform these inputs into the body for the http request as specified by Brevo. Here is the JSONATA expression to add to the Body form to log the right attributes.

{
  "attributes": {
    "note": inputs.note
  },
  "listIds": [
    2
  ],
  "updateEnabled": true,
  "email": inputs.email
}

Should you want to log more attributes (such as a Function, Company, etc), you know how to do: create the right fields in Brevo, add these fields as inputs to the Agent, and add the attributes to the Body as we did above with note.

Step 5: Add the functions to the Agent!

For your Agent to be able to use the functions, get back to Agent > [name_of_your_agent]. Under section Functions, click the + Add button, and add the two functions you just created (”about”, and “create_new_lead”).

Step 6: Test your Agent

Go to Agents > Playground, converse with your agent, and make sure it behaves well and calls the right function when necessary.

At each step of the conversation, you will see the functions called by the agent. Click JSON to see the details of the function calls, and the responses brought by the functions to the agent.

image.png

Step 7: Deploy your agent on your website

You can deploy your agent to your website or mobile app in just one line of code, by using a website embedding.

Please refer to Section 3.5 Deployment 3.5 Deployment under section Website Embedding for a step by step explanation.