Created
April 17, 2023 02:19
-
-
Save jeznag/d65da2219a50fe6f79d640969aba4b74 to your computer and use it in GitHub Desktop.
Sending invoice reminders via SMS from Zoho Books
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
organizationID = organization.get("organization_id"); | |
payment_link_payload = Map(); | |
payment_link_payload.put("customer_id",invoice.get("customer_id")); | |
payment_link_payload.put("payment_amount",invoice.get("total")); | |
payment_link_payload.put("description",invoice.get("invoice_number")); | |
payment_link_payload.put("expiry_time",invoice.get("due_date").toDate().addDay(90)); | |
JSONString = Map(); | |
JSONString.put("JSONString",payment_link_payload); | |
result = invokeurl | |
[ | |
url :"https://books.zoho.com/api/v3/paymentlinks?organization_id=" + organizationID | |
type :POST | |
parameters:JSONString | |
connection:"booksdeluge" | |
]; | |
payment_link = result.get("payment_link").toMap().get("url"); | |
info payment_link; | |
customer = zoho.books.getRecordsByID("Contacts",organizationID,invoice.get("customer_id"),"booksdeluge"); | |
contact_id = customer.get("contact").get("zcrm_contact_id"); | |
matching_contact = zoho.crm.getRecordById("Contacts",contact_id); | |
org_name = organization.get("name"); | |
invoice_amount = invoice.get("balance_formatted"); | |
invoice_number = invoice.get("invoice_number"); | |
due_date = invoice.get("due_date_formatted"); | |
message_name = "Invoice reminder SMS for " + matching_contact.get("First_Name") + " " + matching_contact.get("Last_Name"); | |
message_to_send = "Hi " + matching_contact.get("First_Name") + ", gentle reminder that your invoice " + invoice_number + " from " + org_name + " for " + invoice_amount + " is due on " + due_date + ". Here is a link to pay: " + payment_link; | |
from_number = null; | |
//"+12321412421"; // choose from number | |
new_sms_record_resp = zoho.crm.createRecord("twiliosmsextension0__Sent_SMS",{"Name":message_name,"ContactName":matching_contact.get("id"),"Message":message_to_send,"From":from_number,"To":matching_contact.get("Mobile")},{"trigger":{"workflow"}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment