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: 2 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ runs:

- name: Build
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
env:
BP_VERBOSE: 'true'
run: pnpm build ${{ inputs.extra_filters }}
9 changes: 3 additions & 6 deletions integrations/instagram/integration.definition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { posthogHelper } from '@botpress/common'
import { z, IntegrationDefinition, messages } from '@botpress/sdk'
import { sentry as sentryHelpers } from '@botpress/sdk-addons'
import proactiveConversation from 'bp_modules/proactive-conversation'
import proactiveUser from 'bp_modules/proactive-user'
import { dmChannelMessages } from './definitions/channel'
Expand All @@ -16,7 +16,7 @@ const commonConfigSchema = z.object({

export default new IntegrationDefinition({
name: INTEGRATION_NAME,
version: '4.1.1',
version: '4.1.2',
title: 'Instagram',
description: 'Automate interactions, manage comments, and send/receive messages all in real-time.',
icon: 'icon.svg',
Expand Down Expand Up @@ -165,7 +165,7 @@ export default new IntegrationDefinition({
actions: {},
events: {},
secrets: {
...sentryHelpers.COMMON_SECRET_NAMES,
...posthogHelper.COMMON_SECRET_NAMES,
CLIENT_ID: {
description: 'The client ID of the OAuth Meta app.',
},
Expand All @@ -187,9 +187,6 @@ export default new IntegrationDefinition({
SANDBOX_INSTAGRAM_ID: {
description: 'Instagram ID for the Sandbox Instagram profile',
},
POSTHOG_KEY: {
description: 'The PostHog key for the Instagram integration',
},
},
user: {
tags: {
Expand Down
3 changes: 1 addition & 2 deletions integrations/instagram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"@botpress/client": "workspace:*",
"@botpress/sdk": "workspace:*",
"@botpress/sdk-addons": "workspace:*",
"axios": "^1.6.2",
"posthog-node": "^5.10.4"
"axios": "^1.6.2"
},
"devDependencies": {
"@botpress/cli": "workspace:*",
Expand Down
29 changes: 17 additions & 12 deletions integrations/instagram/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { sentry as sentryHelpers } from '@botpress/sdk-addons'
import { posthogHelper } from '@botpress/common'
import { INTEGRATION_NAME } from 'integration.definition'
import actions from './actions'
import channels from './channels'
import { register, unregister } from './setup'
import { handler } from './webhook'
import * as bp from '.botpress'

const integration = new bp.Integration({
register,
unregister,
actions,
channels,
handler,
@posthogHelper.wrapIntegration({
integrationName: INTEGRATION_NAME,
key: bp.secrets.POSTHOG_KEY,
})
class InstagramIntegration extends bp.Integration {
public constructor() {
super({
register,
unregister,
actions,
channels,
handler,
})
}
}

export default sentryHelpers.wrapIntegration(integration, {
dsn: bp.secrets.SENTRY_DSN,
environment: bp.secrets.SENTRY_ENVIRONMENT,
release: bp.secrets.SENTRY_RELEASE,
})
export default new InstagramIntegration()
49 changes: 0 additions & 49 deletions integrations/instagram/src/misc/posthog-client.ts

This file was deleted.

10 changes: 0 additions & 10 deletions integrations/instagram/src/webhook/handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { isSandboxCommand } from '@botpress/common'
import { Request } from '@botpress/sdk'
import * as crypto from 'crypto'
import { INTEGRATION_NAME } from 'integration.definition'
import { getClientSecret } from 'src/misc/client'
import { sendPosthogError } from 'src/misc/posthog-client'
import {
instagramPayloadSchema,
InstagramLegacyCommentEntry,
Expand Down Expand Up @@ -119,19 +117,11 @@ const _handlerWrapper: typeof _handler = async (props: bp.HandlerProps) => {
if (response && response.status !== 200) {
const errorMessage = `Instagram handler failed with status ${response.status}: ${response.body}`
props.logger.error(errorMessage)
await sendPosthogError(props.ctx.integrationId, errorMessage, {
from: `${INTEGRATION_NAME}:handler`,
integrationName: INTEGRATION_NAME,
})
}
return response
} catch (thrown: unknown) {
const errorMsg = thrown instanceof Error ? thrown.message : String(thrown)
const errorMessage = `Instagram handler failed with error: ${errorMsg}`
await sendPosthogError(props.ctx.integrationId, errorMessage, {
from: `${INTEGRATION_NAME}:handler`,
integrationName: INTEGRATION_NAME,
})
props.logger.error(errorMessage)
return { status: 500, body: errorMessage }
}
Expand Down
9 changes: 3 additions & 6 deletions integrations/messenger/integration.definition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { posthogHelper } from '@botpress/common'
import { z, IntegrationDefinition } from '@botpress/sdk'
import * as sdk from '@botpress/sdk'
import { sentry as sentryHelpers } from '@botpress/sdk-addons'
import proactiveConversation from 'bp_modules/proactive-conversation'
import proactiveUser from 'bp_modules/proactive-user'
import typingIndicator from 'bp_modules/typing-indicator'
Expand Down Expand Up @@ -36,7 +36,7 @@ const replyToCommentsSchema = z.object({

export default new IntegrationDefinition({
name: INTEGRATION_NAME,
version: '5.0.0',
version: '5.0.1',
title: 'Messenger and Facebook',
description:
'Give your bot access to one of the world’s largest messaging platforms and manage your Facebook page content in one place.',
Expand Down Expand Up @@ -164,7 +164,7 @@ export default new IntegrationDefinition({
},
},
secrets: {
...sentryHelpers.COMMON_SECRET_NAMES,
...posthogHelper.COMMON_SECRET_NAMES,
CLIENT_ID: {
description: 'The client ID of your Meta app',
},
Expand Down Expand Up @@ -201,9 +201,6 @@ export default new IntegrationDefinition({
SANDBOX_SHOULD_GET_USER_PROFILE: {
description: "Whether to get the user profile infos from Messenger when creating a new user ('true' or 'false')",
},
POSTHOG_KEY: {
description: 'The PostHog API key',
},
},
user: {
tags: { id: { title: 'User ID', description: 'The Messenger ID of the user' } },
Expand Down
3 changes: 1 addition & 2 deletions integrations/messenger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"@botpress/sdk": "workspace:*",
"@botpress/sdk-addons": "workspace:*",
"axios": "^1.6.2",
"messaging-api-messenger": "^1.1.0",
"posthog-node": "^5.10.4"
"messaging-api-messenger": "^1.1.0"
},
"devDependencies": {
"@botpress/cli": "workspace:*",
Expand Down
29 changes: 17 additions & 12 deletions integrations/messenger/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { sentry as sentryHelpers } from '@botpress/sdk-addons'
import { posthogHelper } from '@botpress/common'
import { INTEGRATION_NAME } from 'integration.definition'
import actions from './actions'
import channels from './channels'
import { register, unregister } from './setup'
import { handler } from './webhook'
import * as bp from '.botpress'

const integration = new bp.Integration({
register,
unregister,
actions,
channels,
handler,
@posthogHelper.wrapIntegration({
integrationName: INTEGRATION_NAME,
key: bp.secrets.POSTHOG_KEY,
})
class MessengerIntegration extends bp.Integration {
public constructor() {
super({
register,
unregister,
actions,
channels,
handler,
})
}
}

export default sentryHelpers.wrapIntegration(integration, {
dsn: bp.secrets.SENTRY_DSN,
environment: bp.secrets.SENTRY_ENVIRONMENT,
release: bp.secrets.SENTRY_RELEASE,
})
export default new MessengerIntegration()
49 changes: 0 additions & 49 deletions integrations/messenger/src/misc/posthog-client.ts

This file was deleted.

10 changes: 0 additions & 10 deletions integrations/messenger/src/webhook/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { isSandboxCommand, meta } from '@botpress/common'
import { INTEGRATION_NAME } from 'integration.definition'
import { sendPosthogError } from 'src/misc/posthog-client'
import { getClientSecret, getVerifyToken } from '../misc/auth'
import { eventPayloadSchema } from '../misc/types'
import { safeJsonParse } from '../misc/utils'
Expand Down Expand Up @@ -64,20 +62,12 @@ const _handlerWrapper: typeof _handler = async (props: bp.HandlerProps) => {
if (response?.status && response.status >= 400) {
const errorMessage = `Messenger handler failed with status ${response.status}: ${response.body}`
props.logger.error(errorMessage)
await sendPosthogError(props.ctx.integrationId, errorMessage, {
from: `${INTEGRATION_NAME}:handler`,
integrationName: INTEGRATION_NAME,
})
}
return response
} catch (thrown: unknown) {
const errorMsg = thrown instanceof Error ? thrown.message : String(thrown)
const errorMessage = `Messenger handler failed with error: ${errorMsg}`
props.logger.error(errorMessage)
await sendPosthogError(props.ctx.integrationId, errorMessage, {
from: `${INTEGRATION_NAME}:handler`,
integrationName: INTEGRATION_NAME,
})
return { status: 500, body: errorMessage }
}
}
Expand Down
2 changes: 1 addition & 1 deletion integrations/twilio/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import proactiveUser from 'bp_modules/proactive-user'
export const INTEGRATION_NAME = 'twilio'
export default new IntegrationDefinition({
name: INTEGRATION_NAME,
version: '1.0.1',
version: '1.0.2',
title: 'Twilio',
description: 'Send and receive messages, voice calls, emails, SMS, and more.',
icon: 'icon.svg',
Expand Down
1 change: 0 additions & 1 deletion integrations/twilio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@botpress/sdk": "workspace:*",
"@botpress/sdk-addons": "workspace:*",
"axios": "^1.6.0",
"posthog-node": "^5.10.4",
"query-string": "^6.14.1",
"twilio": "^3.84.0"
},
Expand Down
18 changes: 12 additions & 6 deletions integrations/twilio/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { RuntimeError } from '@botpress/client'
import { RuntimeError, isApiError } from '@botpress/client'
import { posthogHelper } from '@botpress/common'
import * as sdk from '@botpress/sdk'
import { sentry as sentryHelpers } from '@botpress/sdk-addons'
import axios from 'axios'
import * as crypto from 'crypto'
import { INTEGRATION_NAME } from 'integration.definition'
import queryString from 'query-string'
import { Twilio } from 'twilio'
import { transformMarkdownForTwilio } from './markdown-to-twilio'
import { botpressEvents, sendPosthogEvent } from './posthogClient'
import * as types from './types'
import * as bp from '.botpress'

Expand Down Expand Up @@ -404,10 +405,15 @@ async function sendMessage({ ctx, conversation, ack, mediaUrl, text, logger }: S
} catch (thrown) {
const errMsg = thrown instanceof Error ? thrown.message : String(thrown)
logger.forBot().debug('Failed to transform markdown - Error:', errMsg)
await sendPosthogEvent({
distinctId: errMsg,
event: botpressEvents.UNHANDLED_MARKDOWN,
})
const distinctId = isApiError(thrown) ? thrown.id : undefined
await posthogHelper.sendPosthogEvent(
{
distinctId: distinctId ?? 'no id',
event: 'unhandled_markdown',
properties: { errMsg },
},
{ integrationName: INTEGRATION_NAME, key: bp.secrets.POSTHOG_KEY }
)
}
}
const { sid } = await twilioClient.messages.create({ to, from, mediaUrl, body })
Expand Down
Loading
Loading