Search code examples
corsbotsdocusignapifacebook-messenger

accessing messenger webview javascript extension after loading docusign


From a facebook messenger bot, I want to load a docusign document, have it signed, and upon returning, have the webview window closed and have the bot flow continue. I can do all that if loading a page I own in the webview. When I use the docusign document I tried the 2 following flows: 1-load an html/javascript page I own and let the javascript launch the docusing view. That does not work (xhr returns 0 and docusign does not show) and I believe the reason is that docusign does not allow CORS from my origin. 2-load the docusign page and let docusign know that upon completion, its "returnUrl" will be my html/javascript page, in which I will want to post a fb messenger-like message to my server and close the window for the conversation to continue. That does not work because when docusign loads my page upon return, the fb messenger webview user context is no longer available, meaning I cannot do FB.api anymore as the user token no longer exist. Moreover, in the fb messenger javascript loading callback, I cannot call getUserID anymore, for the same reason. But all I need is the current userid to continue the flow so I also tried to add the userid as a querystring parameter of my html page set in docusign 'returnUrl', but the querystring param gets removed.

The simplest way to achieve this flow would be to have my html/javascript page be able to load the docusign, the way I do for a fb login for example (which implies docusign allows CORS for this), as this would let me have access to the facebook environment, including userid, api and windowClose extension.

Please advise on the proper way to achieve this.


Solution

  • 1-cors is not available in docusign as per their security standards as one user posted: When will the docusign api implement CORS or JSONP?

    2-the userid gets prepended as querystring param, before docusign's event param, and is available to the messenger webview, after the window has initialized.

    The fb api environment is not available.

    Using method 2 does resolve the question.