diff --git a/api/src/chat/services/conversation.service.ts b/api/src/chat/services/conversation.service.ts index 332a64d2..f7bcd775 100644 --- a/api/src/chat/services/conversation.service.ts +++ b/api/src/chat/services/conversation.service.ts @@ -114,16 +114,18 @@ export class ConversationService extends BaseService< contextValue = typeof contextValue === 'string' ? contextValue.trim() : contextValue; - if ( - profile.context?.vars && - contextVars[capture.context_var]?.permanent - ) { - Logger.debug( - `Adding context var to subscriber: ${capture.context_var} = ${contextValue}`, - ); - profile.context.vars[capture.context_var] = contextValue; + if (contextValue) { + if ( + profile.context?.vars && + contextVars[capture.context_var]?.permanent + ) { + Logger.debug( + `Adding context var to subscriber: ${capture.context_var} = ${contextValue}`, + ); + profile.context.vars[capture.context_var] = contextValue; + } + convo.context!.vars[capture.context_var] = contextValue; } - convo.context!.vars[capture.context_var] = contextValue; }); }