Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin-flow-builder: replace bot action id for payload with params in pre funtion #BLT1187 #2929

Conversation

Iru89
Copy link
Contributor

@Iru89 Iru89 commented Nov 4, 2024

Description

Re-apply the old logic for buttons pointing to bot action nodes.
When the user clicks on a button pointing to a bot action, the bot receives in the payload the id of the bot action node. In the plugin's pre function it checks if the id is from a bot action node and if so it replaces the payload with the payload with the parameters defined in the bot action node. This way, when reaching the bot routes, the payload is already the expected one and it is not necessary to make a redirect to run the core-bot again.

Testing

Update test to check that the payload after pre function is the payload with params defined in bot action node

@Iru89 Iru89 requested review from asastre and vanbasten17 and removed request for asastre November 4, 2024 12:56
@Iru89 Iru89 marked this pull request as draft November 4, 2024 12:57
@Iru89 Iru89 requested review from asastre and vanbasten17 and removed request for vanbasten17 November 4, 2024 12:57
@Iru89 Iru89 marked this pull request as ready for review November 4, 2024 14:12
@Iru89 Iru89 force-pushed the BLT-1187-click-on-button-that-targets-bot-action-we-dont-have-to-use-redirect branch from 66bcc0e to bb90422 Compare November 4, 2024 14:14
Copy link

github-actions bot commented Nov 4, 2024

Test Results

30 tests  ±0   30 ✅ ±0   4m 47s ⏱️ +22s
 6 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit bb90422. ± Comparison against base commit e723c40.

♻️ This comment has been updated with latest results.

Comment on lines 113 to +123
if (request.input.payload) {
request.input.payload = this.removeSourceSufix(request.input.payload)
}

if (request.input.payload && this.isBotAction(request.input.payload)) {
const cmsBotAction = this.cmsApi.getNodeById<HtBotActionNode>(
request.input.payload
)

request.input.payload = this.cmsApi.createPayloadWithParams(cmsBotAction)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: You can unify both if (request.input.payload) conditions

packages/botonic-plugin-flow-builder/src/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@vanbasten17 vanbasten17 left a comment

Choose a reason for hiding this comment

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

check @asastre suggestions 👍

@Iru89 Iru89 changed the title refactor(botonic-react): replace bot action id for payload with param… plugin-flow-builder: replace bot action id for payload with params in pre funtion ##BLT1187 Nov 8, 2024
@Iru89 Iru89 changed the title plugin-flow-builder: replace bot action id for payload with params in pre funtion ##BLT1187 plugin-flow-builder: replace bot action id for payload with params in pre funtion #BLT1187 Nov 8, 2024
@Iru89 Iru89 merged commit c62a8f4 into master-lts Nov 11, 2024
4 checks passed
@Iru89 Iru89 deleted the BLT-1187-click-on-button-that-targets-bot-action-we-dont-have-to-use-redirect branch November 11, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants