Error while opening Dialog inside google chat using appscript

I have a add-on app where i have added multiple commands . In that I have a slash command called /share which should open dialog . so its opening and closing after some time and the error says

Server error occurred. Please try again.

Adding my function for more info

Adding reference vide too here

App Link

Thanks in Advance

Hey,

Hope you’re keeping well.

In Google Chat add-ons, dialogs must be opened within the response to an interactive event (such as a slash command) and using the cardsV2 or dialogs API in the same request cycle. If the dialog opens and then closes with a “Server error occurred” message, it usually means the callback isn’t returning the dialog payload properly or is timing out.

Check that your /share command handler responds within the 5‑second limit and includes the actionResponse with type: “DIALOG” in the top‑level response object, rather than triggering it asynchronously. You can verify event payloads and errors in the Apps Script Execution Logs and by enabling Google Chat API logging in the Cloud Console under Monitoring > Logs Explorer.

Thanks and regards,
Taz