Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-integrations-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: ./.github/actions/deploy-integrations
with:
environment: 'production'
extra_filter: "-F '!docusign'"
extra_filter: "-F '!docusign' -F '!whatsapp'"
force: ${{ github.event.inputs.force == 'true' }}
sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }}
token_cloud_ops_account: ${{ secrets.PRODUCTION_TOKEN_CLOUD_OPS_ACCOUNT }}
Expand Down
2 changes: 1 addition & 1 deletion integrations/whatsapp/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const defaultBotPhoneNumberId = {

export default new IntegrationDefinition({
name: INTEGRATION_NAME,
version: '4.5.3',
version: '4.5.4',
title: 'WhatsApp',
description: 'Send and receive messages through WhatsApp.',
icon: 'icon.svg',
Expand Down
2 changes: 1 addition & 1 deletion integrations/whatsapp/linkTemplate.vrl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
webhookId = to_string!(.webhookId)
webhookUrl = to_string!(.webhookUrl)

"{{ webhookUrl }}/oauth/wizard?state={{ webhookId }}"
"{{ webhookUrl }}/oauth/wizard/start-confirm?state={{ webhookId }}"
35 changes: 16 additions & 19 deletions integrations/whatsapp/src/webhook/handlers/oauth/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { Response } from '@botpress/sdk'
import { getSubpath } from 'src/misc/util'
import { getInterstitialUrl, redirectTo } from 'src/webhook/handlers/oauth/html-utils'
import { handleWizard } from './wizard'
import { generateRedirection } from '@botpress/common/src/html-dialogs'
import { isOAuthWizardUrl, getInterstitialUrl } from '@botpress/common/src/oauth-wizard'
import * as wizard from './wizard'
import * as bp from '.botpress'

export const oauthCallbackHandler = async (props: bp.HandlerProps): Promise<Response> => {
export const oauthCallbackHandler: bp.IntegrationProps['handler'] = async (props) => {
const { req, logger } = props
let response: Response
const oauthSubpath = getSubpath(req.path)
try {
if (oauthSubpath?.startsWith('/wizard')) {
response = await handleWizard({ ...props, wizardPath: oauthSubpath })
} else {
response = {
status: 404,
body: 'Invalid OAuth endpoint',
}
if (!isOAuthWizardUrl(req.path)) {
return {
status: 404,
body: 'Invalid OAuth endpoint',
}
} catch (err: any) {
const errorMessage = '(OAuth registration) Error: ' + err.message
}

try {
return await wizard.handler(props)
} catch (thrown: unknown) {
const error = thrown instanceof Error ? thrown : Error(String(thrown))
const errorMessage = 'OAuth registration Error: ' + error.message
logger.forBot().error(errorMessage)
response = redirectTo(getInterstitialUrl(false, errorMessage))
return generateRedirection(getInterstitialUrl(false, errorMessage))
}
return response
}
Loading
Loading