Files
calendar/packages/app-store/intercom/api/initialize.ts
T
Peer RichelsenGitHubpeer@cal.com <peer@cal.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
6f02fbe13b fix: expand Intercom allowed URLs and prevent double-prefixing (#25181)
Co-authored-by: peer@cal.com <peer@cal.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-12-04 05:36:24 +00:00

41 lines
1.2 KiB
TypeScript

import type { NextApiRequest, NextApiResponse } from "next";
import { WEBAPP_URL } from "@calcom/lib/constants";
import type { NewCanvas } from "../lib";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { card_creation_options } = req.body;
if (!card_creation_options) return res.status(400).json({ message: "Missing card_creation_options" });
const URL = `${WEBAPP_URL}/api/integrations/intercom/get?url=${encodeURIComponent(card_creation_options.submit_booking_url)}`;
const canvasData: NewCanvas = {
canvas: {
content: {
components: [
{
type: "text",
text: card_creation_options?.invitation_input ?? "Schedule a meeting with me",
align: "left",
style: "header",
},
{
type: "button",
id: "submit-issue-form",
label: card_creation_options?.booking_button_input ?? "Booking button text",
style: "primary",
action: {
type: "sheet",
url: URL,
},
},
],
},
},
};
return res.status(200).json(canvasData);
}