0

我想使用Google表單中的信息(提交後)使用Docusign API從模板發送信封。如何在Docusign中使用Google表單/文檔中的信息,反之亦然?

信封完成後,我想發送一份不同的Google表單和一份Google文檔給同一個人。另外,我想在完成步驟後發送一些電子郵件。

我曾看過使用Google Apps腳本,它適用於窗體,文檔和電子郵件,但我無法弄清楚如何從那裏運行Docusign API。任何幫助是極大的讚賞。

更新:基於你的幫助,我想出了以下內容。當我運行下面的代碼時,我得到一個錯誤信息:「找不到指定的集成器密鑰或被禁用,沒有指定集成器密鑰。」集成密鑰是活動的,但它可能與重定向URI或密鑰有關?我沒有他們的設置。

// When Form Gets submitted 

function onFormSubmit(e) { 

//Get information from form and set our variables 

    var full_name = e.values[2]; 
    var email_address = e.values[3]; 

// Send the email 

    var subject = "TEST trigger"; 
    var body = "Thank you for testing" + full_name + ""; 

    MailApp.sendEmail(email_address, 
        subject, 
        body); 

// SEND DOCUSIGN ENVELOPE FROM TEMPLATE 

    var url = "https://demo.docusign.net/restApi/v2/accounts/<accountid>/envelopes"; 

    var payload = 
    { 
    "emailSubject": "Please sign stuff", 
    "emailBlurb": "TesttextTesttextTesttextTesttextTesttext", 
    "templateId": "<templateID>", 
    "templateRoles": [ 
    { 
     "roleName": "role1", 
     "name": full_name, 
     "email": email_address 
    }, 
    { 
     "roleName": "role2", 
     "name": "John Doe", 
     "email": "[email protected]" 
    }, 
    { 
     "roleName": "role3", 
     "name": "Joe Smith", 
     "email": "[email protected]" 
    } 
    ], 
    "status": "sent" 
    } 

    var options = 
    { 
    "method" : "post", 
    "header": 
    { 
    "X-DocuSign-Authentication": "{\"Username\":\<username>\",\"Password\":\"<passwork>\",\"IntegratorKey\":\"<integratorkey>\"}" 
    }, 
    "payload" : payload 
    }; 

    UrlFetchApp.fetch(url, options); 
} 

更新:我改變headerheaders,但現在我得到一個不同的錯誤。埃爾金,正如你所建議我登錄請求。以下是錯誤消息。似乎內容類型有問題。

POST https://demo.docusign.net:7802/restApi/v2/accounts/<accountID>/envelopes 

TraceToken: <token> 
Timestamp: 2016-10-24T07:24:27.6912557Z 

Content-Length: 187 
Content-Type: application/x-www-form-urlencoded 
Connection: Keep-alive 
Host: demo.docusign.net 
User-Agent: Mozilla/5.0(compatible; Google-Apps-Script) 
X-DocuSign-Authentication: {"Username":"<my email address>","Password":"[omitted]","IntegratorKey":"[omitted]"} 
X-BROKER-EVENT-ID: AHI413UAlYti8n93Pw-ZxoDmQoiCcwanMroRR1LDTgseOKFBkZVomEVZwdxJ-kajUMDC4NN__Z7e 
X-Forwarded-For: 107.178.203.22 
X-SecurityProtocol-Version: TLSv1.2 
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384 

emailBlurb=TesttextTesttextTesttextTesttextTesttext&templateRoles=%5BLjava.lang.Object;@17be0aa5&templateId=7078020e-49a0-42c6-b77d-368211d4a666&emailSubject=Please+sign+stuff&status=sent 
415 UnsupportedMediaType 
Content-Type: application/json; charset=utf-8 

{ 
    "errorCode": "INVALID_CONTENT_TYPE", 
    "message": "Content Type specified is not supported." 
} 

UPDATE:設置內容類型後,我得到了身體的格式不正確的錯誤。見下面

POST https://demo.docusign.net:7802/restApi/v2/accounts/<accountid>/envelopes 

TraceToken: 0304eb5f-1188-4880-a22c-861839f4e8d9 
Timestamp: 2016-10-25T09:40:49.0423980Z 

Content-Length: 187 
Content-Type: application/json 
Connection: Keep-alive 
Host: demo.docusign.net 
User-Agent: Mozilla/5.0(compatible; Google-Apps-Script) 
X-DocuSign-Authentication: {"Username":"<email>","Password":"[omitted]","IntegratorKey":"[omitted]"} 
X-BROKER-EVENT-ID: AHI413WWv-VgeLRQbOpMQH-Y6J-93aHL4h5phAVpXeXUqK8RsYof90Eu68CI-LkC1Ef4FM8Hac-1 
X-Forwarded-For: 107.178.192.41 
X-SecurityProtocol-Version: TLSv1.2 
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384 
Accept: application/json 

emailBlurb=TesttextTesttextTesttextTesttextTesttext&templateRoles=%5BLjava.lang.Object;@3449f174&templateId=7078020e-49a0-42c6-b77d-368211d4a666&emailSubject=Please+sign+stuff&status=sent 
400 BadRequest 
Content-Type: application/json; charset=utf-8 

{ 
    "errorCode": "INVALID_REQUEST_BODY", 
    "message": "The request body is missing or improperly formatted. Unexpected character encountered while parsing value: e. Path '', line 0, position 0." 
} 

回答

1

你的要求當然會根據你需要做一個HTTP POST請求的幾個因素,比如多少收件人和標籤(場),但在基層從模板發送簽名請求在信封URI在請求體的模板信息:

POST https://demo.docusign.net/restApi/v2/accounts/{accountId}/envelopes 

{ 
    "status": "sent", 
    "emailSubject": "Request a signature via email example", 
    "templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA", 
    "templateRoles": [ 
     { 
      "email": "[email protected]", 
      "name": "John Dough", 
      "roleName": "RoleOne", 
      "tabs": { 
       "textTabs": [ 
        { 
         "tabLabel": "ApplicantName", 
         "value": "John Dough" 
        }, 
        { 
         "tabLabel": "ApplicantSSN", 
         "value": "12-345-6789" 
        } 
       ] 
      } 
     } 
    ] 
} 

您可以測試信封:通過DocuSign API Explorer創建API。

+0

謝謝埃爾金。我可以從我的Google App腳本執行此操作嗎? –

+0

嗨@Ergin,我剛剛發佈了一個更新。你能看看嗎? –

+0

錯誤消息告訴你它無法在請求中找到您的Integrator密鑰,我會檢查並確保您的auth頭已正確連接,假設您傳遞的是有效密鑰。我看到你已經添加了一個'header'節點來添加標題,通常這應該是複數的'headers'。嘗試改變,如果不起作用,那麼你應該在你的帳戶中啓用請求記錄並運行跟蹤,以便檢查傳入的請求。 – Ergin

0

您可以使用Class ItemResponse獲得對錶單中某個問題項的回覆。可以從FormResponse訪問項目響應,並從任何要求答覆者回答問題的項目創建答案。

下面是一個示例代碼段:

// Open a form by ID and log the responses to each question. 
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); 
var formResponses = form.getResponses(); 
for (var i = 0; i < formResponses.length; i++) { 
    var formResponse = formResponses[i]; 
    var itemResponses = formResponse.getItemResponses(); 
    for (var j = 0; j < itemResponses.length; j++) { 
    var itemResponse = itemResponses[j]; 
    Logger.log('Response #%s to the question "%s" was "%s"', 
     (i + 1).toString(), 
     itemResponse.getItem().getTitle(), 
     itemResponse.getResponse()); 
    } 
} 

...但我無法弄清楚如何從那裏運行的DocuSign API。

由於Google Apps腳本可以通過網絡與API進行交互,因此您可以檢查此documentation。如果您想使用Google API或非Google API作爲Apps腳本服務,則可以通過URL Fetch service連接到API的公共HTTP接口。

此服務允許腳本通過提取URL來訪問網絡上的其他資源。腳本可以使用UrlFetch服務來發出HTTP和HTTPS請求並接收響應。 UrlFetch服務使用Google的網絡基礎設施來提高效率和擴展性。

希望這有助於!

相關問題