Shirish Ramchandran
Shirish Ramchandran

Reputation: 3

Docusign API Sending an envelope with SMS using TemplateRole

This is regarding DocuSign Java Client library.

What are the various ways of sending an envelope with SMS using Docusign Java client? I am aware of the setAdditionalNotifications() method in com.docusign.esign.model.Signer class. In which I can assign an object of com.docusign.esign.model.RecipientPhoneNumber. But as per the code examples, if we are using an existing Template to create an envelope then we must use an object of com.docusign.esign.model.TemplateRole instead of Signer object. Since my application uses templates and not hardcoded PDF as documents, I am looking for a method like setAdditionalNotifications() in TemplateRole class. But unable to find any.

What's the best approach to send an envelope with SMS using an existing template. A code snippet would also help.

Upvotes: 0

Views: 206

Answers (1)

Inbar Gazit
Inbar Gazit

Reputation: 14050

Normally, without SMS, you can use TemplateRole, but that doesn't work if you need SMS notifications. In that case you would have to make multiple API calls. First - create envelope from template. Nothing else. Then, you use similar code to below to update the recipients. Lastly, you send it with a third API call

/* example of signer and cc */
      Signer signer = new Signer();
      signer.setEmail(args.getSignerEmail());
      signer.setName(args.getSignerName());
      signer.setRecipientId("1");
      signer.setRoutingOrder("1");
      signer.setTabs(signerTabs);
    
      RecipientAdditionalNotification smsDelivery = new RecipientAdditionalNotification();
      smsDelivery.setSecondaryDeliveryMethod("SMS");
    
      RecipientPhoneNumber phoneNumber = new RecipientPhoneNumber();
      phoneNumber.setCountryCode(args.getCountryCode());
      phoneNumber.setNumber(args.getPhoneNumber());
      smsDelivery.phoneNumber(phoneNumber);
      signer.setAdditionalNotifications(Arrays.asList(smsDelivery));
          
       // Create a cc recipient to receive a copy of the documents, identified by name and email
      CarbonCopy cc = new CarbonCopy();
      cc.setEmail(args.getCcEmail());
      cc.setName(args.getCcName());
      cc.setRecipientId("2");
      cc.setRoutingOrder("2");
          
      RecipientAdditionalNotification ccSmsDelivery = new RecipientAdditionalNotification();
      ccSmsDelivery.setSecondaryDeliveryMethod("SMS");
          
      RecipientPhoneNumber ccPhoneNumber = new RecipientPhoneNumber();
      ccPhoneNumber.setCountryCode(args.getCcCountryCode());
      ccPhoneNumber.setNumber(args.getCcPhoneNumber());
      ccSmsDelivery.phoneNumber(ccPhoneNumber);
      cc.setAdditionalNotifications(Arrays.asList(ccSmsDelivery));
    
/* missing code - build recipients object and add items above */

      envelopesApi.UpdateRecipients(accountId, envelopeId, recipients);

Upvotes: 0

Related Questions