1

I have defined a Triggered Send based on a sendable Data Extension and an EMail AMPScript. I have assigned a external key to the Triggered Send and is sending emails when I create a POST request to the endpoint https://www.exacttargetapis.com/messaging/v1/messageDefinitionSends/external_key/send

I would like to know if there's a way to restart the Triggered Send programatically. I know there's a dashboard UI I can use but I'm not interested in do it manually.

Do you know how to do it? I have tons of Triggered Sends and I'd like to automate the pause/publish/restart process for each TS.

2

EDIT

This is the most optimized solution I could find using AMPScript - albeit part of it is done in SSJS, but that part greatly reduces the code weight and optimizes the speed of the script.

As I was unsure which triggers you wanted to pause or restart, I filtered based on just 'currently active'.

%%[

/************************************

Retrieve Request - list of all Triggered Sends

*************************************/

SET @rr = CreateObject("RetrieveRequest")  
SetObjectProperty(@rr, "ObjectType", "TriggeredSendDefinition")  
AddObjectArrayItem(@rr,"Properties","CustomerKey")  
AddObjectArrayItem(@rr,"Properties","Name")  
AddObjectArrayItem(@rr,"Properties","TriggeredSendStatus")   


/* Invoke the Retrieve Request API */

SET @tsd = InvokeRetrieve(@rr, @Status, @RequestID)  



/*******************************************

FOR loop - to iterate and update all Active Triggers

*******************************************/


FOR @c = RowCount(@tsd) DOWNTO 1  DO    

    SET @row = Row(@tsd ,@c)   
    SET @TSDName = Field(@row ,'Name')   
    SET @TSDKey = Field(@row ,'CustomerKey')
    SET @TSDStatus = Field(@row, 'TriggeredSendStatus')

    IF @TSDStatus == "Active" THEN

]%%

<script runat="server">
Platform.Load("core","1");

var tsdName = Variable.GetValue("@TSDName");
var tsd = TriggeredSend.Init(tsdName);

var pause = tsd.Pause();
var publish = tsd.Publish();
var start = tsd.Start();
</script>


%%[

    ENDIF

NEXT @c
]%%  

I had the same sort of issue and it took a large chunk of my life to solve.

Reference this question/answer for more info on my exact issue: SOAP API to 'publish' a TriggeredSendDefinition?

As I am assuming you want to do a pause, publish and run - See below for API calls which will do a full restart on the triggered email interaction.

You just need to do the requests via the AMPScript API functions.

See below for sample SOAP envelopes to accomplish this:

Pause

<!--***pause***-->

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <soap:Header>
      <wsse:Security soap:mustUnderstand="1">
         <wsse:UsernameToken wsu:Id="UsernameToken-452336374" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>USERNAME</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Objects xsi:type="TriggeredSendDefinition">
        <!-- This section here is only necessary if you are targeting a Welcome Email within a Business Unit -->
            <Client>
               <ID>YOUR_MID</ID>
            </Client>
        <!--END-->
            <CustomerKey>TriggeredSend-customer-key-goes-here</CustomerKey>
            <TriggeredSendStatus>Inactive</TriggeredSendStatus>
         </Objects>
      </UpdateRequest>
   </soap:Body>
</soap:Envelope>

Publish

<!--***publish***-->

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <soap:Header>
      <wsse:Security soap:mustUnderstand="1">
         <wsse:UsernameToken wsu:Id="UsernameToken-452336374" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>MC_USERNAME</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Objects xsi:type="TriggeredSendDefinition">
        <!-- This section here is only necessary if you are targeting a Welcome Email within a Business Unit -->
            <Client>
               <ID>YOUR_MID</ID>
            </Client>
        <!--END-->
            <CustomerKey>TriggeredSend-customer-key-goes-here</CustomerKey>
            <RefreshContent>true</RefreshContent>
         </Objects>
      </UpdateRequest>
   </soap:Body>
</soap:Envelope>

Restart

<!--***restart***-->

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <soap:Header>
      <wsse:Security soap:mustUnderstand="1">
         <wsse:UsernameToken wsu:Id="UsernameToken-452336374" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>USERNAME</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Objects xsi:type="TriggeredSendDefinition">
        <!-- This section here is only necessary if you are targeting a Welcome Email within a Business Unit -->
            <Client>
               <ID>YOUR_MID</ID>
            </Client>
        <!--END-->
            <CustomerKey>TriggeredSend-customer-key-goes-here</CustomerKey>
            <TriggeredSendStatus>Active</TriggeredSendStatus>
         </Objects>
      </UpdateRequest>
   </soap:Body>
</soap:Envelope>
  • I have already done with php sdk github.com/salesforce-marketingcloud/FuelSDK-PHP/blob/master/… .... But I'd like to achieve it inside AMPscript, so do I need to create those separately in SSJS ? – mario ruiz May 15 '17 at 18:36
  • 1
    You can use te ampscript API functions which mimic soap. I apologize they are just soap envelope samples, not ssjs. – Gortonington May 15 '17 at 18:59
  • 1
    @MarioRuiz - I made some edits to my answer that may better help solve your issue. – Gortonington May 18 '17 at 14:26
  • 1
    put it into a content area (inside classic) then call that content block with a SSJS script activity. You can then put that into an automation in Automation Studio. – Gortonington May 26 '17 at 17:18
  • 1
    I have used bash shell scripting and soap calls to restart TSs. Thanks for the soap calls , however I decided to use another way rather than using AMPscript for this – mario ruiz Jun 19 '17 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.