2

I have some AMPScript in my email which makes an external HTTP Request to send additional messages to users.

The email itself is part of a journey which is triggered when a record is created in a Salesforce object.

When I create a new record in the given object, I am sent a single email (which is expected), but the HTTPost request is called twice. Does anyone know why this is?

Here is the HTTP request I am using in my email:

/* SEND SMS */  
set @subscriberKey = AttributeValue("_subscriberkey")  
set @smsMessage = CONCAT('Your booking is at ', @timestamp, '. Dont be late!')
set @customerMobile = lookup("Account_Salesforce","PersonMobilePhone","External_ID__c",@CustomerId)
set @apiToken = "MY API KEY WILL GO HERE"
set @content = CONCAT('{
 "Subscribers": [{"MobileNumber": "', @customerMobile,'", "SubscriberKey": "', @subscriberKey , '"}],
 "Subscribe": true,
 "Resubscribe": true,
 "keyword": "TEST",
 "Override": true,
 "messageText": "', @smsMessage ,'"
}')

var @statusCode
var @response
set @post = HTTPPost2("https://www.exacttargetapis.com/sms/v1/messageContact/Mjo3ODow/send","application/json",@content,false,@statusCode, @response, "Authorization", CONCAT("Bearer " , @apiToken))

1st Edit: I've also tried switching the Subscribers array to mobileNumbers and specified one number but this also sent two messages.

{
    "mobileNumbers": [
    "1122334455667"
    ],
    "Subscribe": true,
    "Resubscribe": true,
    "keyword": "TEST",
    "Override": true,
    "messageText": "This is a test message"
}

2nd Edit: Tried wrapping the code in an IF condition to check if _messageContext equals SEND but this is also failed.

IF _messagecontext == "SEND" AND _IsTestSend == "FALSE" Then
(HTTPPost2 logic goes here)
ENDIF

I have also added _IsTestSend to the condition so the POST request isn't fired when I am testing the email.

1 Answer 1

5

this typically happens because the script is also evaluated for the text only version of the mail. In the text version I usually remove those parts that call external systems (including Salesforce object calls) to avoid this. Drove me insane before I found what it was...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .