Once you have created your first Flow in Globant Enterprise AI following the steps in How to create a Flow, you might want to integrate it with different communication platforms, including B2Chat, to manage agent overflow scenarios (Human-in-the-Loop).
Here is a step-by-step guide on how to connect a Flow through B2Chat.
Go to the URL https://app.b2chat.io and log in.
In the menu on the left, click on General Setting and then select Integrations.

After accessing the Integrations section, select BotApi. There you will see the values corresponding to the username and password you will need.

- Access the Flow you wish to expose. In the Side Navigation Menu, select Configuration and then Application Keys.
- Click on the Generate Key button.

- In the Type field, select API and in Key Name, enter a name such as "B2ChatIntegration". Next, confirm the operation by clicking on Save.

- Copy the generated key using the copy icon next to the key.

Go to the Side Navigation Menu, and click on the Overview option in the Overview section.
There you will see a summary of the Flow including the Bot id, along with other details such as the Flow's name and purpose.
The Bot id is the alphanumeric identifier that appears below the name of your Flow.

Copy the Bot id.
Access the Side Navigation Menu > Configuration > Integrations > B2Chat and fill in the required data:
- Endpoint: It is the B2Chat URL https://api.b2chat.io
- B2Chat webhook: B2Chat uses this URL to answer messages and reach the bot. The URL format is:
https://botbuilder.fluentlab.ai/fluentlab/b2chat/<bot-id>?x-api-key=<api>
- <bot-id>: This is the identifier you obtained in Step 3: Get the Bot id
- <api>: This is the application key you generated in Step 2: Create an application key.
- B2Chat username
- B2Chat password
Once you have configured B2Chat, click on Flow. When doing so, you will notice that now there is a new space available called B2Chat in the Interactions Section:

To create a basic agent escalation flow, you must drag the B2Chat Resolver component into the flow. This component is key because escalation to a human agent will take place at the point where it is inserted.

To test the connection to B2Chat, use the Playground or one of the methods available in Flow (such as Run Flow, Open Testing Assistant, or Go to Demo Page).

Once the flow reaches the B2Chat Resolver, escalation to the human agent will take place. Then, in the B2Chat console, the conversation will appear in the "Chats" tab, and the agent will be able to respond from there.
For the conversation to end in the B2Chat console, the agent must click on "Close". By doing so, the flow will continue to run and activate the next nodes according to the selected configuration.