Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add permanent option context var #67

Merged
merged 11 commits into from
Sep 29, 2024

Conversation

medtaher123
Copy link
Contributor

@medtaher123 medtaher123 commented Sep 22, 2024

Motivation

We need to add a flag for context variables called "permanent" boolean. Currently a context var value is only kept during the current conversation and then gets lost. It would be good to add the "permanent" option allow the value to be stored in the subscriber object in a attribute called "context" (json).

Feature desciption:

There are two types of context variables in Hexabot: non-permanent and permanent.

1. Non-Permanent Context Variables

  • Temporary Storage: Non-permanent context variables are stored in the conversation context.
  • Scope: They are specific to the ongoing conversation and are lost once the conversation ends. This makes them ideal for storing temporary data that is relevant only during the current interaction.
  • Example: If a bot asks a user for their preferred meeting time during a session, the bot may store the response as a non-permanent context variable to use in the rest of the conversation.

2. Permanent Context Variables

  • Persistent Storage: Permanent context variables are stored in the subscriber context, which means they persist across multiple conversations.
  • Scope: These variables retain their values even after a conversation has ended, allowing the bot to remember information about a user across different interactions.
  • Example: If a user provides a preference for a certain feature, such as opting into notifications, the bot can store this preference permanently. The bot will retain this information for future use, without needing to ask the user again in subsequent conversations.

Fixes #48

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (Storybook)
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@medtaher123 medtaher123 self-assigned this Sep 22, 2024
@medtaher123 medtaher123 linked an issue Sep 22, 2024 that may be closed by this pull request
@medtaher123 medtaher123 marked this pull request as draft September 22, 2024 23:30
Copy link
Contributor

@marrouchi marrouchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @medtaher123 Thanks 👏

I think you will need to adapt the unit tests.

api/src/chat/services/conversation.service.ts Outdated Show resolved Hide resolved
api/src/chat/services/conversation.service.ts Outdated Show resolved Hide resolved
@medtaher123
Copy link
Contributor Author

medtaher123 commented Sep 24, 2024

  • Add "permanent" attribute to the context var entity
  • Add "context" attribute in the subscriber entity
  • Capture permanent context vars in the subscriber
  • update unit tests
  • Use the permanent context vars in the token replacement
  • update unit tests
  • add the permanent option in the frontentend contextVars page
  • create a new migration

@medtaher123 medtaher123 marked this pull request as ready for review September 25, 2024 12:12
@marrouchi marrouchi changed the title [DRAFT] Add permanent option context var Add permanent option context var Sep 25, 2024
@marrouchi
Copy link
Contributor

@medtaher123 Thank you 🙏 Can you please add a comment to the field permanent to explain what it does ?
Also, in the PR, add a detailed description of what a permanent context var is compared to a non permanent. Will be used in the documentation ;)

@marrouchi marrouchi merged commit 2f2379d into main Sep 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💡 [REQUEST] - Context vars : Permanent option
2 participants