📁 Showcase
Automation

Automation

1. AutomateWhatsAppInvoice

a. Variables

ensure var VarWhatsappMessage1 kind: text 
  deploy: fixedOnDeploy 
  value: "Hello ${Customer},"

ensure var VarWhatsappMessage2 kind: text 
  deploy: fixedOnDeploy 
  value: "Here is your invoice dated ${Date}, with total ${Amount}." 

ensure var VarWhatsappMessage3 kind: text 
  deploy: fixedOnDeploy 
  value: "Payment link: ${PaymentLink}" 

ensure var VarInvoicePdfName kind: text 
  deploy: fixedOnDeploy 
  value: "Invoice"

ensure var VarMappingGenerateInvoiceDeeplink kind: mapping
  deploy: fixedOnDeploy
  fromForm: OutputInvoice
  toForm: FilterInvoice
  fieldMappingMap: {
    'map': {
      '${f:FromDate}': 'FromDate',
      '${f:ToDate}': 'ToDate',
      '${f:OfficeName}': 'Name',
      '${f:OfficeRowId}': 'OfficeMasterRowId'
    }
  }

b. Automation

ensure automation AutomateWhatsAppInvoice kind: spreadsheet
  spreadsheet: InvoiceHistory

// before insert event
ensure event BeforeInsert fire: beforeInsert

// deeplink generate step for invoice
ensure step GenerateInvoiceDeeplink kind: generateDeeplink
  deeplink: DeeplinkGetInvoice
  deeplinkField: InvoiceLink
  inputFormMappingVar: VarMappingGenerateInvoiceDeeplink

// payment link generate for invoice
ensure step GeneratePaymentLink kind: generatePaymentLink 
  allowedPaymentMethodSet: ["upi"] 
  referenceIdField: Details.InvoiceId 
  spreadsheetRowIdField: $RowId 
  paymentLinkField: Summary.PaymentLink
  currencyValue: "${constant:currency.INR}" 
  amountValue: "${f:Summary.GrandTotal}"
  expiryDurationValue: "${constant:duration.30 days}" 

// pdf generate for invoice
ensure step GenerateInvoicePdf kind: generatePdf 
  pdfField: Summary.InvoicePdf
  contentLayout: FlexMain
  templateLayout: Template
  fileNameVar: {
      'var': 'VarInvoicePdfName'
    }

// after insert event
ensure event AfterInsert fire: afterInsert

// message send on WhatsApp
ensure step MessageSendOnWhatsapp kind: messageSendOnWhatsapp
  dataSourceField: Details.Mobile 
  mediaField: Summary.InvoicePdf 
  templateId: "automation_template_update_document_text_3_v1"
  messageVarMap: [
      "{
        'var': 'VarWhatsappMessage1',
        'paramSet': [
          '${f:Details.OfficeName}'
        ]
      }",
      "{
        'var': 'VarWhatsappMessage2',
        'paramSet': [
          '${f:Details.InvoiceDate}',
          '${f:Summary.GrandTotal}'
        ]
      }",
      "{
        'var': 'VarWhatsappMessage3',
        'paramSet': [
          '${f:Summary.PaymentLink}'
        ]
      }"
    ]

TODO

// message send on WhatsApp
ensure step MessageSendOnWhatsapp kind: messageSendOnWhatsapp
  messageVar: {
      'var': 'VarParagraphInvoiceMessageSendOnWhatsApp',
      'paramSet': [
        '${f:Details.OfficeName}',
        '${f:Details.InvoiceDate}',
        '${f:Summary.GrandTotal}',
        '${f:Summary.InvoiceLink}',
        '${f:Summary.PaymentLink}'
      ]
    }
  dataSourceField: Details.Mobile

ensure step MessageSendOnWhatsapp kind: messageSendOnWhatsapp
  messageVarArray: [
      {
        'var': 'VarParagraphInvoiceMessageSendOnWhatsApp1',
        'paramSet': [
          '${f:Details.OfficeName}',
          '${f:Details.InvoiceDate}',
          '${f:Summary.GrandTotal}',
          '${f:Summary.InvoiceLink}',
          '${f:Summary.PaymentLink}'
        ]
      },
      {
        'var': 'VarParagraphInvoiceMessageSendOnWhatsApp2',
        'paramSet': [
          '${f:Details.PaymentLink}',
          '${f:Details.InvoiceDate}',
          '${f:Summary.GrandTotal}',
          '${f:Summary.InvoiceLink}',
          '${f:Summary.OfficeName}'
        ]
      }
    ]
  dataSourceField: Details.Mobile

2. WebhookRazorpayPayment

a. Variables

ensure var VarMappingPaymentUpdateInvoiceSheet kind: mapping
  deploy: fixedOnDeploy
  toForm: OutputInvoice
  fieldMappingMap: {
    'map': {
      '${d:PaymentStatus.paid}': 'Summary.PaymentStatus'
    }
  }

b. Automation

ensure automation WebhookRazorpayPayment kind: webhook
  callbackKind: razorpayPaymentReceipt

// on callBack  event
ensure event OnCallback fire: onCallback

// update spreadsheet
ensure step UpdateSpreadsheet kind: updateSpreadsheet
  targetSpreadsheet: InvoiceHistory
  rowIdField: SpreadsheetRowId
  sourceToTargetMappingVar: VarMappingPaymentUpdateInvoiceSheet