Files
calendar/packages/app-store/intercom/api/initialize.ts
T
VachmaraandGitHub df598bf281 feat: improve Intercom app (#19687)
* fix: don't POST to cal.com/[user]/[type]

* fix: return html with cal calendar embed

* fix: intercom app team events types

* feat: improve Intercom UX integration

* Merge branch 'main' of https://github.com/calcom/cal.com
2025-03-04 10:48:31 +05:30

41 lines
1.1 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=${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);
}