Skip to content

Conversation

@ceyhun-botpress
Copy link
Contributor

@ceyhun-botpress ceyhun-botpress commented Dec 15, 2025

Chatwoot integration for HITL and messaging channel

@ceyhun-botpress ceyhun-botpress requested a review from a team as a code owner December 15, 2025 23:51
Copilot AI review requested due to automatic review settings December 15, 2025 23:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new Chatwoot integration for Botpress, enabling HITL (Human-in-the-Loop) support and a messaging channel for bot conversations through Chatwoot's platform.

Key Changes:

  • Implements HITL functionality allowing human agents to take over bot conversations
  • Adds a messaging channel for direct bot-to-user communication via Chatwoot
  • Provides webhook handling for bidirectional message synchronization

Reviewed changes

Copilot reviewed 52 out of 54 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
integration.definition.ts Defines integration schema with channels, actions, events, and configuration for Chatwoot API
src/index.ts Main entry point exporting the integration with setup handlers and channels
src/setup/register.ts Validates Chatwoot credentials and stores account configuration during registration
src/setup/handler.ts Processes webhook events from Chatwoot for messages and conversation status changes
src/actions/hitl.ts Implements HITL actions: createUser, startHitl, and stopHitl
src/client.ts Provides API client functions for interacting with Chatwoot's REST API
src/channels.ts Handles message sending for both HITL and messaging channels
package.json Declares dependencies including Botpress SDK, axios, and form-data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@SimonNRisk SimonNRisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: should we add this new integration to the pnpm workspace?

@ptrckbp ptrckbp changed the title feat: ChatWoot Integration feat: Chatwoot Integration Dec 19, 2025
Copy link
Collaborator

@ptrckbp ptrckbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions. There are a lot of fallback behaviors that seem like they could sometimes cause problems.

},
}).extend(hitl, (self) => ({
entities: {
hitlSession: self.entities.ticket,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what does this do exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it implements the standard hitl interface allowing it be compatible with the botpress hitl features

}

try {
const accountId = await getAccountId(client, ctx)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why not just ctx.configuration.accountId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was part of adresing one of the previous comments, but reverted to using ctx.ocnfig.accountid

logger.forBot().info(`Created new conversation: ${chatwootConvId}`)
}

if (description) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: description will never be falsy, this check is redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, removed check

const response = await axios.post(
`${BASE_URL}/accounts/${accountId}/contacts`,
{ email: email, name: email, inbox_id: inboxId },
{ headers: { api_access_token: apiAccessToken } }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Next time you can create a function that wraps axios call and includes auth token and base url, so you don't have to pass them in every time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i made a chatwootClient that returns an AxiosInstance with the baseURL and the access token

const response = await axios.get(`${BASE_URL}/profile`, {
headers: { api_access_token: apiAccessToken },
})
if (response.status !== 200) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This check will never run as axios throws an exception on non 200. You can just omit it or handle it with try/catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled all with try/catch

@ceyhun-botpress ceyhun-botpress dismissed ptrckbp’s stale review December 22, 2025 15:36

merging! ermek approved

@ceyhun-botpress ceyhun-botpress merged commit ce452d5 into master Dec 22, 2025
4 checks passed
@ceyhun-botpress ceyhun-botpress deleted the feat/integration/chatwoot branch December 22, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants