LightningFlowComponents
LightningFlowComponents copied to clipboard
*SendViaMarketingCloud* - _(SendEmailViaMC)_ - contactKey attribute is being used as messageKey in api causing duplicate message key error
Steps to reproduce
Steps to reproduce the behavior:
- Setup a flow and configure the SendEmailViaMC action
- Fill out the required attributes
- Specify a value for the contactKey attribute
- Send a message - it should work
- 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
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?
Reading a little deeper, it sounds like I'm mixing up messageKey and contactKey
ok, I see the problem now...
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.
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/
Legend thanks. I will try it out tomorrow.