…bbles <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ### Summary by CodeRabbit **Release Notes** - New Feature: Enhanced WhatsApp integration with improved phone number formatting and session ID generation. - Refactor: Updated the `startWhatsAppPreview` and `receiveMessagePreview` functions for better consistency and readability. - Bug Fix: Added a check for `phoneNumberId` in the `receiveMessage` function to prevent errors when it's undefined. - Documentation: Expanded the WhatsApp integration guide and FAQs in the docs, providing more detailed instructions and addressing common queries. - Chore: Introduced a new `metadata` field in the `whatsAppWebhookRequestBodySchema` to store the `phone_number_id`. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
12 lines
408 B
TypeScript
12 lines
408 B
TypeScript
import prisma from '@typebot.io/lib/prisma'
|
|
import { sessionStateSchema } from '@typebot.io/schemas'
|
|
|
|
export const getSession = async (sessionId: string) => {
|
|
const session = await prisma.chatSession.findUnique({
|
|
where: { id: sessionId },
|
|
select: { id: true, state: true, updatedAt: true },
|
|
})
|
|
if (!session) return null
|
|
return { ...session, state: sessionStateSchema.parse(session.state) }
|
|
}
|