async function handleNewAttachmentPayload(payload: WebhookNewAttachmentPayload) {
type PackageStatus = {
packageId: string;
delivered: boolean;
}
const { result } = await aiController.generateStructuredContentFromAttachment({
generateStructuredContentAttachmentOptions: {
attachmentId: payload.attachmentId,
instructions: 'Parse attachment and extract package status',
outputSchema: {
type: StructuredOutputSchemaTypeEnum.object,
properties: {
packageId: {
type: StructuredOutputSchemaTypeEnum.string,
description: 'The ID of the package'
},
delivered: {
type: StructuredOutputSchemaTypeEnum.boolean,
description: 'Has the package been delivered?'
}
}
}
}
});
await persistStructuredData(result as PackageStatus);
}