Skip to content

Commit

Permalink
feat: handle empty contact attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmishra committed May 8, 2024
1 parent c90ccb4 commit a8106f5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/canned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,25 @@ export const getMessageVariables = ({
'agent.email': assignee?.email ?? '',
};
const conversationCustomAttributeVariables = Object.entries(
conversationCustomAttributes as CustomAttributes
conversationCustomAttributes
).reduce((acc: CustomAttributes, [key, value]) => {
acc[`conversation.custom_attribute.${key}`] = value;
return acc;
}, {});

const contactCustomAttributeVariables = Object.entries(
contactCustomAttributes as CustomAttributes
).reduce((acc: CustomAttributes, [key, value]) => {
acc[`contact.custom_attribute.${key}`] = value;
return acc;
}, {});
let contactCustomAttributeVariables = {};

if (
contactCustomAttributes &&
Object.keys(contactCustomAttributes).length === 0
) {
contactCustomAttributeVariables = Object.entries(
contactCustomAttributes
).reduce((acc: CustomAttributes, [key, value]) => {
acc[`contact.custom_attribute.${key}`] = value;
return acc;
}, {});
}

const variables = {
...standardVariables,
Expand Down

0 comments on commit a8106f5

Please sign in to comment.