"Frappe is undefined"

When adding a custom button to the CRM portal page, the functionality using frappe.call, frappe.session, etc., is not working, and I’m encountering an “undefined” error for frappe. How can I fix this? I’ve written the code in the CRM from the script in the list. If anyone knows, please help.