Files
botpress--botpress/integrations/asana/src/actions/find-user.ts
T
2026-07-13 13:34:48 +08:00

19 lines
663 B
TypeScript

import { findUserInputSchema } from '../misc/custom-schemas'
import type { IntegrationProps } from '../misc/types'
import { getClient } from '../utils'
export const findUser: IntegrationProps['actions']['findUser'] = async ({ ctx, input, logger }) => {
const validatedInput = findUserInputSchema.parse(input)
const asanaClient = getClient(ctx.configuration)
let response
try {
response = await asanaClient.findUser(validatedInput.userEmail)
logger.forBot().info(`Successful - Find User - ${response.name}`)
} catch (error) {
logger.forBot().debug(`'Find User' exception ${JSON.stringify(error)}`)
response = {}
}
return response
}