2

We have the situation, that we are sending Triggered Emails via REST Api. All subscribers are stored in Triggered Send Data Extension. The Email is the primary key.

In case a user enters an already existing Email the Triggered Email will not be triggered, because the email already exists in the Data Extension. That is correct and expected.

The thing is, in this case the response would still look like this:

"responses": [
    {
        "recipientSendId": "some ID numbers",
        "hasErrors": false,
        "messages": [
            "Queued"
        ]
    }
]

So I find no way to make it possible to give the user an error message on the website saying something like "you email is already in use".

Are there any ideas how to handle that? I guess this case might occur frequently.

  • 1
    You could use Ampscript to check the DE for that primary script and use js or normal text to return the message to the user – Samuel Dare Dec 19 '17 at 15:35
  • Where would Ampscript be used? As the API Call is triggered on a third party Website. Which leads me to the question: Is it possible to speak with the Marketing Cloud via JS from a third party website? – crow_doe Dec 19 '17 at 16:50
1

Your best bet for checking from a third party website is to use two API calls. You would just need to include some logic in your SS language that if the first call is true to put in whatever message you want, but if false then insert.

See calls required below:

  1. Call using SOAP to find out if the entered email address already exists on the Triggered Email list.
  2. Your current Call to add the subscriber to the Triggered List if the result of first call is false.

Below is a sample SOAP envelope for the first call:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Header>
 <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
 <wsse:UsernameToken wsu:Id="UsernameToken-24440876" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
 <wsse:Username>{{YOURUSERNAME}}</wsse:Username>
 <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">{{YOURPASSWORD}}</wsse:Password>
 </wsse:UsernameToken>
 </wsse:Security>
 </soapenv:Header>
 <soapenv:Body>
 <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
 <RetrieveRequest>
 <ObjectType>DataExtensionObject[Example DE]</ObjectType>
 <Properties>EMAIL_ADDRESS</Properties>
 <Properties>CUSTOMER_ID</Properties>
 <Properties>FIRST_NAME</Properties>
 <Properties>SITE_GROUP</Properties>
 <Filter xsi:type="SimpleFilterPart">
 <Property>EMAIL_ADDRESS</Property>
 <SimpleOperator>equals</SimpleOperator>
 <Value>{{YOUREMAILADDRESS}}</Value>
 </Filter>
 </RetrieveRequest>
 </RetrieveRequestMsg>
 </soapenv:Body>
</soapenv:Envelope>

To address your inquiry in the comment - technically yes you can use client-side Javascript to call the API, but that exposes your User/Pass combination to anyone that accesses the page. This would allow any viewer of your page unfettered access to your SFMC account, both via the UI and via API. So usually this is not an option most people would use.

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.