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
25 changes: 22 additions & 3 deletions integrations/trello/definitions/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import { IntegrationDefinitionProps } from '@botpress/sdk'
import { TrelloConfigSchema } from './schemas'
import { IntegrationDefinitionProps, z } from '@botpress/sdk'
import { trelloIdRegex } from './schemas'

const _optionalTrelloIdRegex = new RegExp(`^$|${trelloIdRegex.source}`)

export const configuration = {
schema: TrelloConfigSchema,
schema: z.object({
trelloApiKey: z
.string()
.title('Trello API Key')
.describe('Can be obtained by creating an application on Trello')
.secret(),
trelloApiToken: z
.string()
.title('Trello API Token')
.describe('Can be obtained by granting access to the application on Trello')
.secret(),
trelloBoardId: z
.string()
.regex(_optionalTrelloIdRegex)
.optional()
.title('Trello Board ID')
.describe('Unique identifier of the board to watch for events on Trello'),
}),
} as const satisfies NonNullable<IntegrationDefinitionProps['configuration']>
20 changes: 0 additions & 20 deletions integrations/trello/definitions/schemas/configuration.ts

This file was deleted.

7 changes: 2 additions & 5 deletions integrations/trello/definitions/schemas/entities.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { z } from '@botpress/sdk'

export const trelloIdRegex = /[0-9a-fA-F]{24}/
export const trelloIdRegex = /^[0-9a-fA-F]{24}$/

export const TrelloIDSchema = z
.string()
.length(24)
.regex(new RegExp(`^${trelloIdRegex.source}$`))
export const TrelloIDSchema = z.string().regex(trelloIdRegex)

export type TrelloID = z.infer<typeof TrelloIDSchema>

Expand Down
1 change: 0 additions & 1 deletion integrations/trello/definitions/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './actions/inputSchemas'
export * from './actions/outputSchemas'
export * from './configuration'
export * from './entities'
export * from './states'
export * from './webhookEvents'
2 changes: 1 addition & 1 deletion integrations/trello/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { integrationName } from './package.json'
export default new sdk.IntegrationDefinition({
name: integrationName,
title: 'Trello',
version: '1.1.3',
version: '1.1.4',
readme: 'hub.md',
description: 'Update cards, add comments, create new cards, and read board members from your chatbot.',
icon: 'icon.svg',
Expand Down
14 changes: 13 additions & 1 deletion integrations/zendesk/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { actions, events, configuration, channels, states, user } from './src/de
export default new sdk.IntegrationDefinition({
name: 'zendesk',
title: 'Zendesk',
version: '3.0.2',
version: '3.0.3',
icon: 'icon.svg',
description:
'Optimize your support workflow. Trigger workflows from ticket updates as well as manage tickets, access conversations, and engage with customers.',
Expand Down Expand Up @@ -49,6 +49,18 @@ export default new sdk.IntegrationDefinition({
'Photo URL of the chatbot that will be used in the Zendesk ticket. Must be a publicly-accessible PNG image. Defaults to Botpress logo.'
)
.optional(),
requesterName: sdk.z
.string()
.title('Requester Name')
.describe('The name of the requester the bot was talking to. This will be set in zendesk.')
.optional(),
requesterEmail: sdk.z
.string()
.title('Requester Email')
.describe(
'⚠️This needs a requester name to work. The email of the requester the bot was talking to. This will be set in zendesk.'
)
.optional(),
}),
},
},
Expand Down
11 changes: 8 additions & 3 deletions integrations/zendesk/src/actions/hitl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ export const startHitl: bp.IntegrationProps['actions']['startHitl'] = async (pro
chatbotPhotoUrl,
})

const requester = input.hitlSession?.requesterName
? {
name: input.hitlSession?.requesterName,
...(input.hitlSession?.requesterEmail ? { email: input.hitlSession?.requesterEmail } : {}),
}
: { id: zendeskAuthorId }

const ticket = await zendeskClient.createTicket(
input.title ?? 'Untitled Ticket',
await _buildTicketBody(props, { chatbotName }),
{
id: zendeskAuthorId,
},
requester,
{
priority: input.hitlSession?.priority,
}
Expand Down
4 changes: 2 additions & 2 deletions integrations/zendesk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import * as bp from '.botpress'

export type TicketRequester =
| {
name: string
email: string
name?: string
email?: string
}
| {
id: string
Expand Down
6 changes: 6 additions & 0 deletions integrations/zendesk/src/definitions/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { z } from '@botpress/sdk'
import { omit } from 'lodash'

const requesterSchema = z.object({
name: z.string().optional(),
email: z.string().optional(),
})

export const ticketSchema = z.object({
id: z.number(),
subject: z.string(),
description: z.string(),
status: z.enum(['new', 'open', 'pending', 'hold', 'solved', 'closed']),
priority: z.enum(['low', 'normal', 'high', 'urgent']).nullable(),
requesterId: z.number(),
requester: requesterSchema.optional(),
assigneeId: z.number().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cli",
"version": "5.1.1",
"version": "5.1.2",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
Expand Down
9 changes: 1 addition & 8 deletions packages/cli/src/command-implementations/add-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as sdk from '@botpress/sdk'
import * as fslib from 'fs'
import * as pathlib from 'path'
import semver from 'semver'
import * as apiUtils from '../api'
import * as codegen from '../code-generation'
import type commandDefinitions from '../command-definitions'
Expand Down Expand Up @@ -108,13 +107,7 @@ export class AddCommand extends GlobalCommand<AddCommandDefinition> {
await this._uninstall(installPath)
}

if (ref.type === 'name' && ref.version === pkgRef.LATEST_TAG) {
// If the semver version expression is 'latest', we assume the project
// is compatible with all versions of the latest major:
const major = semver.major(targetPackage.pkg.version)
targetPackage.pkg.version = `>=${major}.0.0 <${major + 1}.0.0`
} else if (ref.type === 'name') {
// Preserve the semver version expression in the generated code:
if (ref.type === 'name') {
targetPackage.pkg.version = ref.version
}

Expand Down
2 changes: 1 addition & 1 deletion packages/zai/src/operations/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const extract = async <S extends OfType<AnyObjectOrArray>>(
try {
schema = transforms.fromJSONSchema(transforms.toJSONSchema(_schema as any as z.ZodType))
} catch {
// The above transformers arent the legacy once. They are very strict and might fail on some schema types.
// The above transformers arent the legacy ones. They are very strict and might fail on some schema types.
schema = _schema as any as z.ZodType
}

Expand Down
Loading