LightningFlowComponents icon indicating copy to clipboard operation
LightningFlowComponents copied to clipboard

*SendViaMarketingCloud* - _(SendEmailViaMC)_ - contactKey attribute is being used as messageKey in api causing duplicate message key error

Open lemerv opened this issue 1 year ago • 4 comments

Steps to reproduce

Steps to reproduce the behavior:

  1. Setup a flow and configure the SendEmailViaMC action
  2. Fill out the required attributes
  3. Specify a value for the contactKey attribute
  4. Send a message - it should work
  5. Send another message - it will NOT work

Expected behaviour

The second email should send

Actual behaviour

It does not send and an error is returned from the api

Debug Logs

Duplicate MessageKey error:

[{"messageKey":"0033C00000aJlA0XXX","errorcode":109110,"message":"MCMS_UTM_Validation_DuplicateMessageKey: messageKey reused within the past 2 days"}]})

The issue is that when a contactKey is specified, this is being appended to the callout url, effectively setting it as the messageKey. Since messageKey must be unique for every send, this causes the error. See final callout url below, where as per the api spec, the [0033C00000aJlA0XXX] is where the messageKey goes, but that is actually the value from contactKey in the action.

https://mcxxxxxxxxxxxxxxxxxxxxxxx.rest.marketingcloudapis.com/messaging/v1/email/messages/0033C00000aJlA0XXX

lemerv avatar Oct 14 '22 05:10 lemerv

Thanks for the report! I thought that the current behavior is the desired behavior, to prevent duplicate messages. Can you expand on what the expected behavior should be and why?

alexed1 avatar Oct 14 '22 21:10 alexed1

Reading a little deeper, it sounds like I'm mixing up messageKey and contactKey

alexed1 avatar Oct 14 '22 21:10 alexed1

ok, I see the problem now...

alexed1 avatar Oct 14 '22 21:10 alexed1

No worries. Let me know if you need more clarification. Thanks

I posted this corresponding feature request (https://github.com/alexed1/LightningFlowComponents/issues/1237) to be able to set the messageKey as an input variable in the action config screen. This is what would be appended to the end of the callout url.

lemerv avatar Oct 15 '22 08:10 lemerv

ok, new version 1.1 fixes the behavior of both messageKey and contactKey, and messageKey is now an optional input. Let me know if you get a chance to try it. https://unofficialsf.com/using-flow-with-salesforce-cdp-marketing-cloud-messaging/

alexed1 avatar Oct 15 '22 22:10 alexed1

Legend thanks. I will try it out tomorrow.

lemerv avatar Oct 15 '22 23:10 lemerv