Action

Message Preset

Posted by @mattmaybe, Last update almost 6 years ago

Send a message to 4 preset contacts. The draft will be tagged with the contacts name and then a message will be sent to that contact. There is now the option to send via iMessage or through drafts messaging.

Please note you will need to add the contact names and telephone numbers in the scripting section.

Steps

  • script

    //SHARED MESSAGE PRESET
    
    var p = Prompt.create();
    var tUrl = "sms://";
    
    // contacts 
    var contact1 = ["insert contact name","inserts contact number"];
    var contact2 = ["insert contact name","inserts contact number"];
    var contact3 = ["insert contact name","inserts contact number"];
    var contact4 = ["insert contact name","inserts contact number"];
    
    // set buttons
    
    p.addButton(contact1[0]);
    p.addButton(contact2[0]);
    p.addButton(contact3[0]);
    p.addButton(contact4[0]);
    
    p.addSwitch("switch", "Open in iMessage", false);
    
    // show buttons
    
    var didSelect = p.show();
    
    // contact 1
    
    if (p.buttonPressed == contact1[0]) {
      var tel = contact1[1];
      var contact = contact1[0]; 
    }
    
    // contact 2
    
    if (p.buttonPressed == contact2[0]) {
      var tel = contact2[1];
      var contact = contact2[0]; 
    }
    
    // contact 3
    
    if (p.buttonPressed == contact3[0]) {
      var tel = contact3[1];
      var contact = contact3[0]; 
    }
    
    // contact 4
    
    if (p.buttonPressed == contact4[0]) {
      var tel = contact4[1];
      var contact = contact4[0]; 
    } 
    if (!tel) {
    alert("No selection");
    } else {
    // test switch
    if (p.fieldValues["switch"] == true) {
    
    // tag update
    var d = draft.content;
    draft.addTag(contact);
    draft.update();
    
    
    //build the final url
    var finalUrl = encodeURI(sms + tel + "&body=" + d);
    
    //open url
    var result = app.openURL(finalUrl);
    
    } 
    else {
    var msg = Message.create();
    msg.toRecipients = [tel];
    msg.body = draft.content;
    
    var success = msg.send();
    
    // tag update
    var d = draft.content;
    draft.addTag(contact);
    draft.update();
    }
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.