I have a custom action that should update the customer email however the data action updates the agent email instead of the customer (I believe due to updating context.email). Is is possible to filter by .purpose in the Request Body Template or is there a better way? This is what I have:
Contracts: conversationID, participantID, email
Request URL Template:
/api/v2/conversations/{input.conversationId}/participants/{input.participantId}/attributes
Request Body Template:
{
"attributes": {
"context.email": "${input.email}"
}
}
Where are you triggering this data action from?
From an Architect flow? Or from a Script (agent's script)?
Just asking as the answer will be different (Script has some built-in variables which are not available in Architect flow).
And just to be sure - when you say "update the customer email" - are you referring to data/attributes which would be set on a WebChat conversation?
Just checking that you are not referring to the from address of an email conversation.
In this case, you can leverage some Script built-in variables in your data action input parameters.
ConversationID corresponds to {{Scripter.Interaction Id}}
The ParticipantID which corresponds to the customer's participantId is {{Scripter.Customer Participant ID}}
Passing them in your data action input parameters (that uses /api/v2/conversations/{input.conversationId}/participants/{input.participantId}/attributes) will allow to update the attributes under customer's participant (which is where the WebChat widget attributes/data are stored).
NB: I mean keep your data action contract and configuration - just pass the Script built-variables mentioned above as input from the Script.
One more comment:
When you update the context.email attribute, I think the email address which appears in the Interaction Details tab will not reflect it.
Interaction Details is loaded on chat answer.
If you want to check it, transfer the chat back to a queue/another user. The second user will see the updated email address in Interaction Details.