Skip to content

Commit

Permalink
feat: expose setConversationCustomAttributes method (#149)
Browse files Browse the repository at this point in the history
This commit exposes the method setConversationCustomAttributes from
Chatwoot.
  • Loading branch information
luannmoreira authored Nov 29, 2024
1 parent 67f8f5b commit f3db807
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const { isModalVisible, toggle, toggleBubbleVisibility, popoutChatWindow } = use
| toggle | `'open' or 'close' - Function ` | You can open and close the chat |
| setUser | `key: string, args: ChatwootSetUserProps - Function` | You can send user information to chatwoot panel. |
| setCustomAttributes | `attributes: { [key: string]: string } - Function` | You can send custom attributes to chatwoot panel. |
| setConversationCustomAttributes | `attributes: { [key: string]: string } - Function` | You can send conversation custom attributes to chatwoot panel. |
| deleteCustomAttribute | `key: string - Function` | You can delete custom attributes to chatwoot panel. |
| setLocale | `local: string - Function` | Change widget locale |
| setLabel | `label: string - Function` | You can send label to chatwoot panel. |
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/vue/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface Chatwoot {
toggle: (state?: 'open' | 'close') => void
setUser: (key: string, args: ChatwootSetUserProps) => void
setCustomAttributes: (attributes: { [key: string]: string }) => void
setConversationCustomAttributes: (attributes: { [key: string]: string }) => void
deleteCustomAttribute: (key: string) => void
setLocale: (local: string) => void
setLabel: (label: string) => void
Expand Down Expand Up @@ -286,6 +287,12 @@ export function useChatWoot() {
isLoadTimer().then(() => window.$chatwoot.setCustomAttributes(attributes))
}

const setConversationCustomAttributes = (
attributes: Parameters<Chatwoot['setConversationCustomAttributes']>[0],
) => {
isLoadTimer().then(() => window.$chatwoot.setConversationCustomAttributes(attributes))
}

const deleteCustomAttribute = (
attributes: Parameters<Chatwoot['deleteCustomAttribute']>[0],
) => {
Expand Down Expand Up @@ -327,6 +334,7 @@ export function useChatWoot() {
toggle,
setUser,
setCustomAttributes,
setConversationCustomAttributes,
deleteCustomAttribute,
setLocale,
setLabel,
Expand Down

0 comments on commit f3db807

Please sign in to comment.