We are using Docusign REST integration in our managed package, but right now it is not real time. we send the sign envelope request to Docusign and then do the continous polling for response of the docusign signing process. Now Docusign have a limitation here with polling it won't allow you poll very frequent you can only poll once in a 15 minutes time period.
You are not allowed to poll DocuSign more than once every 15 minutes. To ensure that your app has an accurate view of your envelopes’ statuses, we suggest that you poll every 17-20 minutes.
see reference here: https://developers.docusign.com/esign-rest-api/code-examples/polling-for-envelope-status
Now we wanted to make it real time where user sees the response immediately and get the signed document back into salesforce, as an alternative which is also recommended by Docusign is expose the web-hooks listner in your app side, those web-hooks listeners will be called by Docusign Event system which send the response back to your listener as soon as there is any event happened. when we submit the envelope request we can mention our webhook listener url which will be called by Docusign for that particular envelope response and statues.
In order to expose a webhook listner, Docusign recommend it should be available in public internet without authentication, where docusign can post the statues. Now a days that API also support a basic authentication like username password, but again in that case also they will only do the API call once only.
See below link for auth based webhook listener service. https://www.docusign.com/blog/dsdev-securing-connect-webhook-listener/
Now in Salesforce how can we implement this webhook listener, I've tried some ways, and really wanted to know more on that. A best and suitable approach.
- With username-password authentication approach: We can send SF Integration user username password along with the request which can be used by Docusign to make the webhook listener connect call. Now as per Docusign it will be a single call where they call our listner and pass the auth parameters, but in sales-force if we follow username/password based auth approach any application has to make two API calls, first one to get session and then consecutive call to do actual operation.
- Expose a public REST service in Salesforce: We can expose a REST Service class on public by using Salesforce Sites, but again for that we require to have a salesforce site, for that there will be additional configuration and user have to purchase site licenses if they don't have.
- Host the webhook outside of salesforce: Host an another instance for this webhook Service listener and then then do salesforce poll to this hosted environment.
Really need to know if we can have an alternative here.
P.S: we can't use Docusign for salesforce connect, beacuse we have a custom requirement here.