Get interactions
Use .GetAsync<Interaction>() / .Get<Interaction>() to retrieve an interaction or set of interactions. Interactions can be retrieved by:
-
A combination of interaction ID and contact ID
-
A combination of interaction ID and contact reference
The contact ID or contact reference is included to increase the efficiency of the query in a sharded environment. Collection data is sharded on contact ID, so including the contact ID in the query means that xConnect immediately knows which shard holds the interaction data.
In the following example, two interactions are retrieved.
When requesting a list of interactions, your return type will be a list of operation results, not a list of contacts. The return type is ReadOnlyCollection<IEntityLookupResult<Contact>>. When looping through this collection, you can access the Interaction object itself through the Entity property on each EntityLookupResult<Interaction> object. Recommended practices is to check if the Interaction is null or check if the entity Exists. The associated Exception is also available for each operation result.
If you are getting a single contact, you can use the .GetContactAsync() method. If you are getting more than one contact, use the .GetAsync<Contact>() as it performs better.
Get interaction events
Interactions are always returend with all available events. Refer to Get interaction events for more information about working with the different types of events.
Get interaction facets and related contact
By default, interactions are returned without facets or the related contact. Use expand options to determine which facets and contact information should be returned: