DocuSign API: Assign a delivery method to a TemplateRole to send SMS to a signer

144 Views Asked by At

I'm trying to make it so that specific signers to a document can be sent an envelope via SMS instead of email. I am using server templates to create the envelopes, but the examples don't seem to agree on whether to use a TemplateRole or use a Signer to create the envelope. So far I've been using TemplateRole, but it does not seem like there is a delivery method option (for only SMS).

In looking for answers I found a small reference to a bug "TT-3902" that was referenced two years ago and also on a post to the Java SDK, but at the same time another post from a year ago says it is possible - but the link to the API Explorer shows only using a Signer object, not a TemplateRole object...

Questions: Can I use the TemplateRole this way but haven't found the right example? Is there a workaround? Has bug TT-3902 been fixed? Do I need to recode my entire Envelope creation process to be different just to use the Signer objects instead?

Current Code (using Python SDK):

            signer = TemplateRole(
                role_name=signer_provided["role_name"],
                name=signer_provided["name"],
                email=signer_provided["email"],
                tabs=tabs,
            )

What I want to program for SMS delivery:

            phone_number = RecipientPhoneNumber(country_code="1", number=signer_provided["phone_number"])
            signer = TemplateRole(
                delivery_method="SMS",
                role_name=signer_provided["role_name"],
                name=signer_provided["name"],
                phone_number=phone_number,
                tabs=tabs,
            )

I also tried:

            phone_number = RecipientPhoneNumber(country_code="1", number=signer_provided.get("phone_number"))
            additional_notification = RecipientAdditionalNotification(secondary_delivery_method="SMS", phone_number=phone_number)
            signer = TemplateRole(
                additional_notification=additional_notification,
                role_name=signer_provided["role_name"],
                name=signer_provided["name"],
                email=signer_provided["email"],
                tabs=tabs,
            )

But this only sent an email (using my developer account) and not an SMS at all. I would like it to only send via SMS in this case.

1

There are 1 best solutions below

2
On BEST ANSWER

You will need to use Composite Templates for this to work

Here is what the JSON looks like:

{
  "envelopeDefinition": {
    "status": "sent",
    "compositeTemplates": [
      {
        "compositeTemplateId": "1",
        "serverTemplates": [
          {
            "sequence": "1",
            "templateId": "1b66677c-xxxx-xxxx-xxxx-655a7c3890d9"
          }
        ],
        "inlineTemplates": [
          {
            "sequence": "1",
            "recipients": {
              "signers": [
                {
                  "name": "Signer Name",
                  "roleName": "signer",
                  "deliveryMethod": "SMS",
                  "recipientId": "1",
                  "phoneNumber": {
                    "countryCode": "",
                    "number": ""
                  },
                  "tabs": {
                    "textTabs": [
                      {
                        "tabLabel": "signer_title",
                        "value": "Manager"
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    ]
  },
  "envelopesCreateQP": {}
}