Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Node.js Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Node.js) Yousign - Setup email notifications

Demonstrates how to setup email notifications based on events. An event is triggered when a user (or our API) make an action or when a status has changed.

For more information, see https://dev.yousign.com/?version=latest#96b9f5ec-8e41-4d0f-82e5-6fa91adfa4fd

Install Chilkat for Node.js and Electron using npm at

Chilkat npm packages for Node.js

Chilkat npm packages for Electron

on Windows, Linux, MacOSX, and ARM

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}

function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    // Implements the following CURL command:

    // curl --location --request POST 'https://staging-api.yousign.com/procedures' \
    // --header 'Authorization: Bearer YOUR_API_KEY' \
    // --header 'Content-Type: application/json' \
    // --data-raw '{
    //     "name": "My first procedure with emails",
    //     "description": "Powerful! Here is the description of my first procedure with emails",
    //     "members": [
    //         {
    //             "firstname": "John",
    //             "lastname": "Doe",
    //             "email": "john.doe@yousign.fr",
    //             "phone": "+33612345678",
    //             "fileObjects": [
    //                 {
    //                     "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //                     "page": 2,
    //                     "position": "230,499,464,589",
    //                     "mention": "Read and approved",
    //                     "mention2": "Signed by John Doe"
    //                 }
    //             ]
    //         }
    //     ],
    //     "config": {
    //         "email": {
    //             "member.started": [
    //                 {
    //                     "subject": "Hey! You are invited to sign!",
    //                     "message": "Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>",
    //                     "to": ["@member"]
    //                 }
    //             ],
    //             "procedure.started": [
    //                 {
    //                     "subject": "John, created a procedure your API have.",
    //                     "message": "The content of this email is totally awesome.",
    //                     "to": ["@creator", "@members", "billing@yousign.fr"]
    //                 }
    //             ]
    //         }
    //     }
    // }'

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "name": "My first procedure with emails",
    //   "description": "Powerful! Here is the description of my first procedure with emails",
    //   "members": [
    //     {
    //       "firstname": "John",
    //       "lastname": "Doe",
    //       "email": "john.doe@yousign.fr",
    //       "phone": "+33612345678",
    //       "fileObjects": [
    //         {
    //           "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //           "page": 2,
    //           "position": "230,499,464,589",
    //           "mention": "Read and approved",
    //           "mention2": "Signed by John Doe"
    //         }
    //       ]
    //     }
    //   ],
    //   "config": {
    //     "email": {
    //       "member.started": [
    //         {
    //           "subject": "Hey! You are invited to sign!",
    //           "message": "Hello <tag data-tag-type=",
    //           " data-tag-name=": <tag,
    //           "button": [
    //             "@member"
    //           ]
    //         }
    //       ],
    //       "procedure.started": [
    //         {
    //           "subject": "John, created a procedure your API have.",
    //           "message": "The content of this email is totally awesome.",
    //           "to": [
    //             "@creator",
    //             "@members",
    //             "billing@yousign.fr"
    //           ]
    //         }
    //       ]
    //     }
    //   }
    // }

    var json = new chilkat.JsonObject();
    json.UpdateString("name","My first procedure with emails");
    json.UpdateString("description","Powerful! Here is the description of my first procedure with emails");
    json.UpdateString("members[0].firstname","John");
    json.UpdateString("members[0].lastname","Doe");
    json.UpdateString("members[0].email","john.doe@yousign.fr");
    json.UpdateString("members[0].phone","+33612345678");
    // Use the actual file ID here...
    json.UpdateString("members[0].fileObjects[0].file","/files/23686fbe-3ae1-4de9-9e01-58bbf29b2b18");
    json.UpdateInt("members[0].fileObjects[0].page",2);
    json.UpdateString("members[0].fileObjects[0].position","230,499,464,589");
    json.UpdateString("members[0].fileObjects[0].mention","Read and approved");
    json.UpdateString("members[0].fileObjects[0].mention2","Signed by John Doe");
    json.UpdateString("config.email.\"member.started\"[0].subject","Hey! You are invited to sign!");
    json.UpdateString("config.email.\"member.started\"[0].message","Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>");
    json.UpdateString("config.email.\"member.started\"[0].to[0]","@member");
    json.UpdateString("config.email.\"procedure.started\"[0].subject","John, created a procedure your API have.");
    json.UpdateString("config.email.\"procedure.started\"[0].message","The content of this email is totally awesome.");
    json.UpdateString("config.email.\"procedure.started\"[0].to[0]","@creator");
    json.UpdateString("config.email.\"procedure.started\"[0].to[1]","@members");
    json.UpdateString("config.email.\"procedure.started\"[0].to[2]","billing@yousign.fr");

    // Adds the "Authorization: Bearer YOUR_API_KEY" header.
    http.AuthToken = "YOUR_API_KEY";
    http.SetRequestHeader("Content-Type","application/json");

    // resp: HttpResponse
    var resp = http.PostJson3("https://staging-api.yousign.com/procedures","application/json",json);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    var sbResponseBody = new chilkat.StringBuilder();
    resp.GetBodySb(sbResponseBody);
    var jResp = new chilkat.JsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.EmitCompact = false;

    console.log("Response Body:");
    console.log(jResp.Emit());

    var respStatusCode = resp.StatusCode;
    console.log("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        console.log("Response Header:");
        console.log(resp.Header);
        console.log("Failed.");

        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "id": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //   "name": "My first procedure with emails",
    //   "description": "Powerful! Here is the description of my first procedure with emails",
    //   "createdAt": "2018-12-05T06:53:34+01:00",
    //   "updatedAt": "2018-12-05T06:53:34+01:00",
    //   "finishedAt": null,
    //   "expiresAt": null,
    //   "status": "active",
    //   "creator": null,
    //   "creatorFirstName": null,
    //   "creatorLastName": null,
    //   "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //   "template": false,
    //   "ordered": false,
    //   "parent": null,
    //   "metadata": [
    //   ],
    //   "config": {
    //     "email": {
    //       "procedure.started": [
    //         {
    //           "subject": "John, created a procedure your API have.",
    //           "message": "The content of this email is totally awesome.",
    //           "to": [
    //             "@creator",
    //             "@members",
    //             "billing@yousign.fr"
    //           ]
    //         }
    //       ],
    //       "member.started": [
    //         {
    //           "subject": "Hey! You are invited to sign!",
    //           "message": "Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>",
    //           "to": [
    //             "@member"
    //           ]
    //         }
    //       ]
    //     }
    //   },
    //   "members": [
    //     {
    //       "id": "/members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //       "user": null,
    //       "type": "signer",
    //       "firstname": "John",
    //       "lastname": "Doe",
    //       "email": "john.doe@yousign.fr",
    //       "phone": "+33612345678",
    //       "position": 1,
    //       "createdAt": "2018-12-05T06:53:34+01:00",
    //       "updatedAt": "2018-12-05T06:53:34+01:00",
    //       "finishedAt": null,
    //       "status": "pending",
    //       "fileObjects": [
    //         {
    //           "id": "/file_objects/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //           "file": {
    //             "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //             "name": "The best name for my file.pdf",
    //             "type": "signable",
    //             "contentType": "application/pdf",
    //             "description": null,
    //             "createdAt": "2018-12-05T06:52:54+01:00",
    //             "updatedAt": "2018-12-05T06:53:34+01:00",
    //             "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2",
    //             "metadata": [
    //             ],
    //             "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //             "creator": null,
    //             "protected": false,
    //             "position": 0,
    //             "parent": null
    //           },
    //           "page": 2,
    //           "position": "230,499,464,589",
    //           "fieldName": null,
    //           "mention": "Read and approved",
    //           "mention2": "Signed by John Doe",
    //           "createdAt": "2018-12-05T06:53:34+01:00",
    //           "updatedAt": "2018-12-05T06:53:34+01:00",
    //           "parent": null,
    //           "reason": "Signed by Yousign"
    //         }
    //       ],
    //       "comment": null,
    //       "notificationsEmail": [
    //       ],
    //       "operationLevel": "custom",
    //       "operationCustomModes": [
    //         "sms"
    //       ],
    //       "operationModeSmsConfig": null,
    //       "parent": null
    //     }
    //   ],
    //   "subscribers": [
    //   ],
    //   "files": [
    //     {
    //       "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //       "name": "The best name for my file.pdf",
    //       "type": "signable",
    //       "contentType": "application/pdf",
    //       "description": null,
    //       "createdAt": "2018-12-05T06:52:54+01:00",
    //       "updatedAt": "2018-12-05T06:53:34+01:00",
    //       "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2",
    //       "metadata": [
    //       ],
    //       "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //       "creator": null,
    //       "protected": false,
    //       "position": 0,
    //       "parent": null
    //     }
    //   ],
    //   "relatedFilesEnable": false,
    //   "archive": false,
    //   "archiveMetadata": [
    //   ],
    //   "fields": [
    //   ],
    //   "permissions": [
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    var subject;
    var message;
    var j;
    var count_j;
    var strVal;
    var user;
    var v_type;
    var firstname;
    var lastname;
    var email;
    var phone;
    var position;
    var comment;
    var operationLevel;
    var operationModeSmsConfig;
    var fileId;
    var fileName;
    var fileType;
    var fileContentType;
    var fileDescription;
    var fileCreatedAt;
    var fileUpdatedAt;
    var fileSha256;
    var fileWorkspace;
    var fileCreator;
    var fileProtected;
    var filePosition;
    var fileParent;
    var page;
    var position_str;
    var fieldName;
    var mention;
    var mention2;
    var reason;
    var k;
    var count_k;
    var contentType;
    var sha256;
    var v_protected;

    var id = jResp.StringOf("id");
    var name = jResp.StringOf("name");
    var description = jResp.StringOf("description");
    var createdAt = jResp.StringOf("createdAt");
    var updatedAt = jResp.StringOf("updatedAt");
    var finishedAt = jResp.StringOf("finishedAt");
    var expiresAt = jResp.StringOf("expiresAt");
    var status = jResp.StringOf("status");
    var creator = jResp.StringOf("creator");
    var creatorFirstName = jResp.StringOf("creatorFirstName");
    var creatorLastName = jResp.StringOf("creatorLastName");
    var workspace = jResp.StringOf("workspace");
    var template = jResp.BoolOf("template");
    var ordered = jResp.BoolOf("ordered");
    var parent = jResp.StringOf("parent");
    var relatedFilesEnable = jResp.BoolOf("relatedFilesEnable");
    var archive = jResp.BoolOf("archive");
    var i = 0;
    var count_i = jResp.SizeOfArray("metadata");
    while (i < count_i) {
        jResp.I = i;
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("config.email.\"procedure.started\"");
    while (i < count_i) {
        jResp.I = i;
        subject = jResp.StringOf("config.email.\"procedure.started\"[i].subject");
        message = jResp.StringOf("config.email.\"procedure.started\"[i].message");
        j = 0;
        count_j = jResp.SizeOfArray("config.email.\"procedure.started\"[i].to");
        while (j < count_j) {
            jResp.J = j;
            strVal = jResp.StringOf("config.email.\"procedure.started\"[i].to[j]");
            j = j+1;
        }

        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("config.email.\"member.started\"");
    while (i < count_i) {
        jResp.I = i;
        subject = jResp.StringOf("config.email.\"member.started\"[i].subject");
        message = jResp.StringOf("config.email.\"member.started\"[i].message");
        j = 0;
        count_j = jResp.SizeOfArray("config.email.\"member.started\"[i].to");
        while (j < count_j) {
            jResp.J = j;
            strVal = jResp.StringOf("config.email.\"member.started\"[i].to[j]");
            j = j+1;
        }

        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("members");
    while (i < count_i) {
        jResp.I = i;
        id = jResp.StringOf("members[i].id");
        user = jResp.StringOf("members[i].user");
        v_type = jResp.StringOf("members[i].type");
        firstname = jResp.StringOf("members[i].firstname");
        lastname = jResp.StringOf("members[i].lastname");
        email = jResp.StringOf("members[i].email");
        phone = jResp.StringOf("members[i].phone");
        position = jResp.IntOf("members[i].position");
        createdAt = jResp.StringOf("members[i].createdAt");
        updatedAt = jResp.StringOf("members[i].updatedAt");
        finishedAt = jResp.StringOf("members[i].finishedAt");
        status = jResp.StringOf("members[i].status");
        comment = jResp.StringOf("members[i].comment");
        operationLevel = jResp.StringOf("members[i].operationLevel");
        operationModeSmsConfig = jResp.StringOf("members[i].operationModeSmsConfig");
        parent = jResp.StringOf("members[i].parent");
        j = 0;
        count_j = jResp.SizeOfArray("members[i].fileObjects");
        while (j < count_j) {
            jResp.J = j;
            id = jResp.StringOf("members[i].fileObjects[j].id");
            fileId = jResp.StringOf("members[i].fileObjects[j].file.id");
            fileName = jResp.StringOf("members[i].fileObjects[j].file.name");
            fileType = jResp.StringOf("members[i].fileObjects[j].file.type");
            fileContentType = jResp.StringOf("members[i].fileObjects[j].file.contentType");
            fileDescription = jResp.StringOf("members[i].fileObjects[j].file.description");
            fileCreatedAt = jResp.StringOf("members[i].fileObjects[j].file.createdAt");
            fileUpdatedAt = jResp.StringOf("members[i].fileObjects[j].file.updatedAt");
            fileSha256 = jResp.StringOf("members[i].fileObjects[j].file.sha256");
            fileWorkspace = jResp.StringOf("members[i].fileObjects[j].file.workspace");
            fileCreator = jResp.StringOf("members[i].fileObjects[j].file.creator");
            fileProtected = jResp.BoolOf("members[i].fileObjects[j].file.protected");
            filePosition = jResp.IntOf("members[i].fileObjects[j].file.position");
            fileParent = jResp.StringOf("members[i].fileObjects[j].file.parent");
            page = jResp.IntOf("members[i].fileObjects[j].page");
            position_str = jResp.StringOf("members[i].fileObjects[j].position");
            fieldName = jResp.StringOf("members[i].fileObjects[j].fieldName");
            mention = jResp.StringOf("members[i].fileObjects[j].mention");
            mention2 = jResp.StringOf("members[i].fileObjects[j].mention2");
            createdAt = jResp.StringOf("members[i].fileObjects[j].createdAt");
            updatedAt = jResp.StringOf("members[i].fileObjects[j].updatedAt");
            parent = jResp.StringOf("members[i].fileObjects[j].parent");
            reason = jResp.StringOf("members[i].fileObjects[j].reason");
            k = 0;
            count_k = jResp.SizeOfArray("members[i].fileObjects[j].file.metadata");
            while (k < count_k) {
                jResp.K = k;
                k = k+1;
            }

            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("members[i].notificationsEmail");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("members[i].operationCustomModes");
        while (j < count_j) {
            jResp.J = j;
            strVal = jResp.StringOf("members[i].operationCustomModes[j]");
            j = j+1;
        }

        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("subscribers");
    while (i < count_i) {
        jResp.I = i;
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("files");
    while (i < count_i) {
        jResp.I = i;
        id = jResp.StringOf("files[i].id");
        name = jResp.StringOf("files[i].name");
        v_type = jResp.StringOf("files[i].type");
        contentType = jResp.StringOf("files[i].contentType");
        description = jResp.StringOf("files[i].description");
        createdAt = jResp.StringOf("files[i].createdAt");
        updatedAt = jResp.StringOf("files[i].updatedAt");
        sha256 = jResp.StringOf("files[i].sha256");
        workspace = jResp.StringOf("files[i].workspace");
        creator = jResp.StringOf("files[i].creator");
        v_protected = jResp.BoolOf("files[i].protected");
        position = jResp.IntOf("files[i].position");
        parent = jResp.StringOf("files[i].parent");
        j = 0;
        count_j = jResp.SizeOfArray("files[i].metadata");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("archiveMetadata");
    while (i < count_i) {
        jResp.I = i;
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("fields");
    while (i < count_i) {
        jResp.I = i;
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("permissions");
    while (i < count_i) {
        jResp.I = i;
        i = i+1;
    }


}

chilkatExample();

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.