feat(integrations/wechat): implement integration#14940
Merged
JustinBordage merged 77 commits intomasterfrom Mar 16, 2026
Merged
feat(integrations/wechat): implement integration#14940JustinBordage merged 77 commits intomasterfrom
JustinBordage merged 77 commits intomasterfrom
Conversation
Contributor
Author
|
This PR is a rework of the integration from PR #14852. It cleans up the logic making it easier to maintain and using best practices from the Botpress organization. |
…hannelMessage" function
Contributor
Greptile SummaryThis PR introduces a new WeChat Official Account integration for Botpress, implementing inbound webhook message handling (text, image, video, voice, location, link), outbound messaging (text, image, and video-as-text), access token caching with expiry refresh, media download/upload via Botpress file storage, and webhook signature verification. Key observations:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant WX as WeChat Platform
participant H as handler.ts
participant S as signature.ts
participant I as inbound.ts
participant C as WeChatClient
participant A as auth.ts
participant BP as Botpress SDK
WX->>H: POST /webhook (XML message)
H->>S: verifyWebhookSignature()
S-->>H: valid/invalid
alt Invalid signature
H-->>WX: 403 Forbidden
end
H->>I: processInboundChannelMessage()
I->>I: _parseAndValidateWeChatXmlMessage() [primary parser]
alt Primary parser fails
I->>I: _fallbackParseAndValidateWeChatMessage() [regex parser]
end
I->>BP: getOrCreateConversation()
I->>BP: getOrCreateUser()
alt text message
I->>BP: createMessage(text)
else image/video message
I->>A: getOrRefreshAccessToken()
A->>A: check cached token expiry
alt Token expired or missing
A->>WX: GET /token (fetch fresh token)
A->>BP: setState (cache token)
end
I->>C: downloadWeChatMedia(mediaId)
C->>WX: GET /media/get
I->>BP: uploadFile()
I->>BP: createMessage(image/video)
else voice message
I->>BP: createMessage(text "[Voice Message]...")
else location/link message
I->>BP: createMessage(text)
end
H-->>WX: 200 OK
Note over WX,H: Outbound (bot → user)
BP->>H: channel.messages.text/image/video
H->>A: getOrRefreshAccessToken()
alt image
H->>C: downloadMediaFromURL() + uploadMedia()
C->>WX: POST /media/upload
end
H->>C: sendMessage()
C->>WX: POST /message/custom/send
Last reviewed commit: bcc980b |
Math-Fauch
previously approved these changes
Mar 14, 2026
Math-Fauch
previously approved these changes
Mar 16, 2026
Math-Fauch
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves SH-423