onRecorderOpenedonRecorderClosedonRecordingStartedonRecordingStoppedonRecordingPosted
You must register them from the birdieSettings object, as shown into the example below:
<script>window.my_callback_recorder_opened = function() {console.log("The recorder popup has been opened")// you own code…};window.my_callback_recorder_closed = function() {console.log("The recorder popup has been closed")// you own code…};window.my_callback_recording_started = function() {console.log("The recording has just started")// you own code…};window.my_callback_recording_stopped = function() {console.log("The recording has just stopped")// you own code…};window.my_callback_recording_posted = function(link) {console.log("The recording was sent, the sharing link is:", link)// you own code can use the the sharing link given as parameter…};window.birdieSettings = {// other settings… onRecorderOpened: my_callback_recorder_opened, onRecorderClosed: my_callback_recorder_closed, onRecordingStarted: my_callback_recording_started, onRecordingStopped: my_callback_recording_stopped, onRecordingPosted: my_callback_recording_posted};</script>
React code example
// BirdieButton.tsximport React, { useCallback, useEffect } from'react';import firebase from'api/firestore/rebase';import styles from'./styles.module.scss';exportconstBirdieButton= () => {useEffect(() => {if (typeof window ==='undefined') return;if (window.innerWidth <=768) return; // birdie doesn't work on mobileif (window.birdie) return; // prevent fetching on every new page if already existsconstcurrentUser=firebase.auth().currentUser;window.birdieSettings = { app_id: '#######', // replace ####### with your own identifier found in settings page at https://app.birdie.so/settings/inapp
contact_name:currentUser?.displayName, contact_email:currentUser?.email, contact_id:currentUser?.uid, };constscript=document.createElement('script');script.type ='text/javascript';script.async =true;script.src ='https://app.birdie.so/widget/'+window.birdieSettings.app_id; document.body.appendChild(script); }, []);consthandleClick=useCallback(() => {if (window.birdie.widget.opened()) {window.birdie?.widget.close(); } else {window.birdie?.widget.open(); } }, []);return ( <buttontype="button"onClick={handleClick} className={styles.headerButton}>Feedback</button> );};// which requires this type wherever types are defined:declare global {interfaceWindow { birdie: { widget: {opened: () =>boolean; open:VoidFunction; close:VoidFunction; }; }; birdieSettings: { app_id:string; contact_name?:string|null; contact_email?:string|null; contact_id?:string; }; }}
Example: Add Birdie to a custom ticket form using the Web SDK
A common use case involves using the Web SDK to integrate Birdie into a custom ticket form. While you're free to get creative, here are three different ways Birdie could be added to the Active Campaign ticket form: