- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - dixa #15261
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
          
     Merged
      
      
    
  
     Merged
                    New Components - dixa #15261
Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      9dbb4f1
              
                dixa init
              
              
                luancazarine 389b3b1
              
                [Components] dixa #15252
              
              
                luancazarine 2061d81
              
                Merge branch 'master' into issue-15252
              
              
                luancazarine 2622f7b
              
                pnpm update
              
              
                luancazarine 9fccf17
              
                some adjusts
              
              
                luancazarine a726726
              
                Update components/dixa/actions/add-message/add-message.mjs
              
              
                luancazarine d321a80
              
                some adjusts
              
              
                luancazarine fac7e49
              
                fix add-message data
              
              
                luancazarine File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import dixa from "../../dixa.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "dixa-add-message", | ||
| name: "Add Message to Conversation", | ||
| description: "Adds a message to an existing conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations/#tag/Conversations/operation/postConversationsConversationidMessages).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| dixa, | ||
| endUserId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "endUserId", | ||
| ], | ||
| }, | ||
| conversationId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "conversationId", | ||
| ({ endUserId }) => ({ | ||
| endUserId, | ||
| }), | ||
| ], | ||
| }, | ||
| content: { | ||
| type: "string", | ||
| label: "Content", | ||
| description: "Content of the message", | ||
| }, | ||
| direction: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "direction", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| agentId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "agentId", | ||
| ], | ||
| }, | ||
| }, | ||
| async additionalProps(props) { | ||
| props.agentId.hidden = !this.direction === "Outbound"; | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.dixa.addMessage({ | ||
| $, | ||
| conversationId: this.conversationId, | ||
| data: { | ||
| content: { | ||
| agentId: this.direction === "Outbound" | ||
| ? this.agentId | ||
| : undefined, | ||
| value: this.content, | ||
| _type: "Text", | ||
| }, | ||
| _type: this.direction, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Added message to conversation ${this.conversationId}`); | ||
| return response; | ||
| }, | ||
|         
                  GTFalcao marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
        
          
          
            102 changes: 102 additions & 0 deletions
          
          102 
        
  components/dixa/actions/create-conversation/create-conversation.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import dixa from "../../dixa.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "dixa-create-conversation", | ||
| name: "Create Conversation", | ||
| description: "Creates a new email or contact form-based conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations/#tag/Conversations/operation/postConversations).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| dixa, | ||
| requesterId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "endUserId", | ||
| ], | ||
| label: "Requester Id", | ||
| }, | ||
| direction: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "direction", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| channel: { | ||
| type: "string", | ||
| label: "Channel", | ||
| description: "For outbound, only Email is supported. Inbound also supports ContactForm.", | ||
| options: [ | ||
| "Email", | ||
| "ContactForm", | ||
| ], | ||
| }, | ||
| emailIntegrationId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "emailIntegrationId", | ||
| ], | ||
| }, | ||
| subject: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "subject", | ||
| ], | ||
| }, | ||
| message: { | ||
| type: "string", | ||
| label: "Message", | ||
| description: "The content message.", | ||
| }, | ||
| language: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "language", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| agentId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "agentId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async additionalProps(props) { | ||
| props.agentId.hidden = !this.direction === "Outbound"; | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| props.channel.options = this.direction === "Outbound" | ||
| ? [ | ||
| "Email", | ||
| ] | ||
| : [ | ||
| "ContactForm", | ||
| "Email", | ||
| ]; | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.dixa.createConversation({ | ||
| $, | ||
| data: { | ||
| subject: this.subject, | ||
| emailIntegrationId: this.emailIntegrationId, | ||
| language: this.language, | ||
| requesterId: this.requesterId, | ||
| message: { | ||
| agentId: this.direction === "Outbound" | ||
| ? this.agentId | ||
| : undefined, | ||
| content: { | ||
| _type: "Text", | ||
| value: this.message, | ||
| }, | ||
| _type: this.direction, | ||
| }, | ||
| _type: this.channel, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Created conversation with Id: ${response.data.id}`); | ||
| return response; | ||
| }, | ||
|         
                  GTFalcao marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
        
          
          
            98 changes: 98 additions & 0 deletions
          
          98 
        
  components/dixa/actions/set-custom-contact-attributes/set-custom-contact-attributes.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import dixa from "../../dixa.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "dixa-set-custom-contact-attributes", | ||
| name: "Set Custom Contact Attributes", | ||
| description: "Updates custom attributes for a specified user. [See the documentation]()", | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| dixa, | ||
| userId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "endUserId", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| const { data } = await this.dixa.listCustomAttributes(); | ||
|  | ||
| for (const item of data) { | ||
| if (item.isDeactivated || item.isArchived || item.entityType != "Contact") continue; | ||
|  | ||
| props[item.id] = { | ||
| type: "string", | ||
| label: item.label, | ||
| description: item.description, | ||
| optional: !item.isRequired, | ||
| default: item.inputDefinition.placeholder, | ||
| }; | ||
|  | ||
| if (item.inputDefinition._type === "Select") { | ||
| props[item.id].options = this.prepareOptions(item.inputDefinition.options); | ||
| } | ||
| } | ||
| return props; | ||
| }, | ||
|         
                  luancazarine marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| methods: { | ||
| prepareOptions(options, parentVal = "", parentLabel = "") { | ||
| const newOptions = []; | ||
|  | ||
| for (const opt of options) { | ||
| const newLabel = parentLabel | ||
| ? `${parentLabel} - ${opt.label}` | ||
| : opt.label; | ||
|  | ||
| const newVal = parentVal | ||
| ? `${parentVal}/${opt.value}` | ||
| : opt.value; | ||
|  | ||
| if (opt.nestedOptions.length) { | ||
| newOptions.push(...this.prepareOptions(opt.nestedOptions, newVal, newLabel)); | ||
| } else { | ||
| newOptions.push({ | ||
| label: newLabel, | ||
| value: newVal, | ||
| }); | ||
| } | ||
| } | ||
| return newOptions; | ||
| }, | ||
| async prepareData(data) { | ||
| const response = {}; | ||
| const { data: customAttributes } = await this.dixa.listCustomAttributes(); | ||
| Object.entries(data).map(([ | ||
| key, | ||
| val, | ||
| ]) => { | ||
| const customAttribute = customAttributes.find((attr) => attr.id === key); | ||
|  | ||
| response[key] = customAttribute.inputDefinition._type != "Text" | ||
| ? val.split("/") | ||
| : val; | ||
| }); | ||
| return response; | ||
| }, | ||
|         
                  GTFalcao marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| dixa, | ||
| // eslint-disable-next-line no-unused-vars | ||
| prepareOptions, | ||
| prepareData, | ||
| userId, | ||
| ...data | ||
| } = this; | ||
|  | ||
| const response = await dixa.updateCustomAttributes({ | ||
| $, | ||
| userId, | ||
| data: await prepareData(data), | ||
| }); | ||
|         
                  luancazarine marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| $.export("$summary", `Updated custom attributes for user ${this.userId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
        
          
          
            42 changes: 42 additions & 0 deletions
          
          42 
        
  components/dixa/actions/tag-conversation/tag-conversation.mjs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import dixa from "../../dixa.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "dixa-tag-conversation", | ||
| name: "Add Tag to Conversation", | ||
| description: "Adds a tag to a conversation. [See the documentation](https://docs.dixa.io/openapi/dixa-api/v1/tag/Tags/#tag/Tags/operation/putConversationsConversationidTagsTagid)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| dixa, | ||
| endUserId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "endUserId", | ||
| ], | ||
| }, | ||
| conversationId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "conversationId", | ||
| ({ endUserId }) => ({ | ||
| endUserId, | ||
| }), | ||
| ], | ||
| }, | ||
| tagId: { | ||
| propDefinition: [ | ||
| dixa, | ||
| "tagId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.dixa.addTag({ | ||
| $, | ||
| conversationId: this.conversationId, | ||
| tagId: this.tagId, | ||
| }); | ||
| $.export("$summary", `Added tag ${this.tagId} to conversation ${this.conversationId}`); | ||
| return response; | ||
| }, | ||
|         
                  GTFalcao marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }; | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| export const parseObject = (obj) => { | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| if (!obj) return undefined; | ||
|  | ||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.