0

1. Can't add new interaction with historical date

This is the only way to add new interaction problematically

new Interaction(contact, InteractionInitiator, channelId, userAgent);

and as you can see, I can't provide the CreationDate or the LastModified date.

I believe this is due to Auditing reasons but at the same time we have a lot of other operations, aside from the happy scenario in production. like(performance testing, Integration testing, demos, ...etc.) this is not acceptable by today's standards.

2. Can't Edit interaction facets

If you ever tried to get an already existing interaction to add some new facet to it. you will face this error.

{ "Message": "Facets cannot be added to existing interaction" }

e.g. Try to get interaction by id client.GetAsync then client.SetFacet<IpInfo> then client.SubmitAsync() when the interaction in the db doesn't have this facet.

Is there is any reason why I can't do this simple operation?

2

Updating interaction facets is definitely something that has been discussed but at the current time it is a product decision to keep these consistent. If you wish to 'change' the value of an interaction, you need to delete the existing one and create a new one. (This leads to the next problem where you cannot currently delete a single interaction via the API). At the time of writing, no version of the xConnect API supports an atomic interaction delete.

As for specifying a time of an event, you will want to use code like the following:

//Instantiate the interaction details
var interaction = new Interaction(contact, InteractionInitiator.Brand, channelId, userAgent);

//Create a timestamp (myDateTimeValue being something you have passed in to your method)
var interactionTimestamp = myDateTimeValue.HasValue? myDateTimeValue.Value : DateTime.UtcNow;

//Create the event with your custom time
var xConnectEvent = new Goal(Guid.Parse(goalId), interactionTimestamp);

//Add the event to the interaction
interaction.Events.Add(xConnectEvent);
| improve this answer | |
0

When contact interacts with a brand/medium/organization, either online or offline, that particular action or point is known as Interaction. In Sitecore, Interactions are represented by the Sitecore.XConnect.Interaction class and must have at least one event. When you create an interaction, you need to pass ChannelId, Initiatorand UserAgent mandatory properties into the constructor. VenueId and CampaignId are the optional properties for the interaction.

Now coming to your questions, It is not possible to update an interaction once it has been submitted to xConnect. You can only update the contacts, see the link for update contacts - https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/update-contacts.html.
Since every Interaction must have at least one event, so an interaction’s StartDateTime, EndDateTime, and Duration are calculated using the interaction’s event timestamps and duration. So when you add new interaction problematically, you need to define at least one event and you can pass the StartDateTime in that event. This event could be a Goal, outcome or PageViewEvent see the link for adding interaction event - https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/add-interaction-events.html

| improve this answer | |

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.