Prefill web widget | Community
Skip to main content

Prefill web widget

  • October 27, 2022
  • 2 replies
  • 0 views

SAI15

HI

I am facing issues while prefilling name & email to web widget. I am able to open chat on page load but unable to prefill name & email

<!DOCTYPE html>
            <html lang="en">
            <head>
              <meta charset="UTF-8">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <meta http-equiv="X-UA-Compatible" content="ie=edge">
              <title>Chat</title>
              <!-- Start of Zendesk Widget script -->
              <script id="ze-snippet"
                src="https://static.zdassets.com/ekr/snippet.js?key=<yourKey>"> </script>
              <!-- End of Zendesk Widget script -->
              <style type="text/css">html { background: #243553; }</style>
            </head>
            <body>
            <script>
            document.addEventListener( 'DOMContentLoaded', function( event ) {
                zE('messenger', 'open');
                // zE('webWidget', 'prefill', {
                //   name: { value: "test User", readOnly: true },
                //   email: { value: "testuser@gmail.com", readOnly: true },
                //   phone: { value: "1234567987", readOnly: true }
                // });
               
            });
            </script>
            </body>
            </html>

Error:
Method webWidget.prefill does not exist.

A note from Zendesk: API methods associated with the Web Widget (Classic) are still being executed on this page. This website is now using the new Web SDK (messaging experience) which no longer supports these APIs. If you don't intend to use the Web Widget (Classic), we recommend that you remove this code from your website.  Whilst not recommended, leaving them won't cause any issues. 

2 replies

Tipene
  • October 28, 2022

Hey @sai15,

By the looks of the error message you're receiving, your account has messaging enabled. This means that you'll be using the new Zendesk Web Widget, which operates off of a separate API for widget commands. Here's a link to the reference which goes in to more detail:

https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/sdks/web/sdk_api_reference/

At this time, prefill is not a supported command when using the Zendesk web widget.

Feel free to reach out if you have any questions!

Tipene 


SAI15
  • Author
  • November 1, 2022

Thanks for your response.

I think we can achieve with the below article
https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/sdks/web/enabling_auth_visitors/