đ Branch Overview and Goal
This branch is activated when a user, who has already received a first reply from the bot, sends a follow-up message. The primary goal is to maintain a contextual conversation, provide further assistance, and intelligently determine the next step: either resolve the issue and close the chat, or escalate it to a human agent. This branch has an advanced AI agent with a richer set of rules and tools.
đ Key Input Data for This Phase:
- A follow-up message from a user in an existing Intercom conversation.
- The user's email, which already exists in the Baserow database.
- The pre-existing ThreadID associated with the user from the database.
đ Key Output Data from This Phase:
- A contextual follow-up message sent to the user.
- A decision to either:
- Close the conversation if the issue is resolved.
- Reassign the conversation to a live agent if the user requests it.
đ§ŠÂ Step-by-Step Breakdown
Step 2.1: Identifying a Returning User
This entire branch is predicated on the system recognizing that this is not the user's first message to the bot.
âĄď¸ Triggering Gateway (after Node 5): The branch starts here.
- đŻ Purpose: To route the scenario down this "follow-up" path instead of the "first contact" path.
- đ§ Key Logic:Â The gateway condition isÂ
{{not(empty($5.body.results))}
}. This checks the output of the database lookup (Node 5) and proceeds only if the result is not empty, meaning the user's email was found and they already have a conversation history with the bot.
Step 2.2: Preparing the Context for the AI
Before invoking the AI, the workflow gathers all the necessary information to ensure the agent has full context of the ongoing conversation.
âĄď¸ Nodes & Logic: A Set Variables node is used to consolidate the user's new message with their existing session ID.
đ§ Node 21: Set Variables - Store the User Reply
- đŻ Purpose: To prepare a clean, structured input for the conversational AI agent.
- đ§ Key Logic:
- It sets a question variable to the new message body ({{15.msg_body}}).
- Crucially, it retrieves the existing session_id from the database lookup result: {{$35.body.results.[0].ThreadID}}. This session_id is the key to maintaining a stateful, continuous conversation.
- đĽ Input: The latest message from the user (via Node 15) and the database query result (from Node 5).
<aside>
đ¤
Output: Two variables: question (the new prompt) and session_id (the existing conversation context).
</aside>
Step 2.3: Engaging the Advanced Conversational AI Agent