Skip to content

Commit 148d308

Browse files
committed
'externalAttributes #145'
The `externalAttributes` attribute is an optional field that can be used to add custom information or metadata to the message being sent. This field is useful for attaching additional data that you want to track or associate with the message throughout the sending and receiving process without affecting the main content of the message. ### Details of the `externalAttributes` Attribute - **Type:** `string` - **Description:** This field can accept various types of values, including simple strings, booleans, numbers, JSON objects, or JSON arrays. Below are the specifications for the accepted data types: - `[string]` - A simple text string. - `[string[boolean]]` - A string representing a boolean value. - `[string[number]]` - A string representing a numeric value. - `[string[Json[Object]]]` - A string containing a JSON object. - `[string[Json[Array]]]` - A string containing a JSON array. ### Usage When you create a message and include the `externalAttributes` field, the specified values are transmitted along with the message. These values are then forwarded to the associated webhook, providing a way to "stamp" the message with additional information that can be used for tracking, auditing, or other analytical or processing purposes. For example, you could use `externalAttributes` to store a user ID, process status, or any other relevant information you want to associate with the message. When the message is processed by the target system or responded to via webhook, these external attributes are included in the payload of the response, allowing you to use them as needed in your workflow.
1 parent 6ed3793 commit 148d308

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

docs/swagger.yaml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ servers:
161161
- url: http://{dev_host}
162162
variables:
163163
dev_host:
164-
default: 127.0.0.1:8084
164+
default: localhost:8084
165165

166166
paths:
167167
/instance/qrcode/{instanceName}:
@@ -486,6 +486,7 @@ paths:
486486
example:
487487
number: 123@broadcast
488488
options:
489+
externalAttributes: <any> - optional
489490
delay: 1200
490491
presence: composing
491492
textMessage:
@@ -605,6 +606,7 @@ paths:
605606
example:
606607
number: <string> - required
607608
options:
609+
externalAttributes: <any> - optional
608610
delay: <integer> - optional
609611
presence: <'composing' | 'recording' | 'paused'> - optional
610612
quotedMessageId: 1
@@ -656,7 +658,7 @@ paths:
656658
format: binary
657659
mediatype:
658660
type: string
659-
description: '-required - image | document | video | audio'
661+
description: '- **required:** image | document | video | audio'
660662
example: document
661663
presence:
662664
type: string
@@ -670,6 +672,21 @@ paths:
670672
type: integer
671673
description: '- optional'
672674
example: '1883'
675+
externalAttributes:
676+
type: string
677+
description: |
678+
- optional
679+
680+
---
681+
682+
**Types:**
683+
684+
- `[string]`
685+
- `[string[boolean]]`
686+
- `[string[number]]`
687+
- `[string[Json[Object]]]`
688+
- `[string[Json[Array]]]`
689+
673690
parameters:
674691
- name: instanceName
675692
in: path
@@ -740,6 +757,7 @@ paths:
740757
example:
741758
number: <string> - required
742759
options:
760+
externalAttributes: <any> - optional
743761
delay: <integer> - optional
744762
presence: <'composing' | 'recording' | 'paused'> - optional
745763
quotedMessageId: 1
@@ -782,6 +800,7 @@ paths:
782800
example:
783801
number: <string> - required
784802
options:
803+
externalAttributes: <any> - optional
785804
delay: <integer> - optional
786805
presence: <'composing' | 'recording' | 'paused'> - optional
787806
quotedMessageId: 1
@@ -863,6 +882,7 @@ paths:
863882
example:
864883
number: <string> - required
865884
options:
885+
externalAttributes: <any> - optional
866886
delay: <integer> - optional
867887
quotedMessageId: 1
868888
audioMessage:
@@ -920,6 +940,21 @@ paths:
920940
type: string
921941
description: Optional ID of the message to be quoted in the conversation.
922942
example: "12345"
943+
externalAttributes:
944+
type: string
945+
description: |
946+
- optional
947+
948+
---
949+
950+
**Types:**
951+
952+
- `[string]`
953+
- `[string[boolean]]`
954+
- `[string[number]]`
955+
- `[string[Json[Object]]]`
956+
- `[string[Json[Array]]]`
957+
923958
responses:
924959
'200':
925960
description: Audio file sent successfully.
@@ -967,6 +1002,7 @@ paths:
9671002
description: "The recipient's phone number."
9681003
example: "5531900000000"
9691004
options:
1005+
externalAttributes: <any> - optional
9701006
type: object
9711007
properties:
9721008
delay:
@@ -1054,6 +1090,7 @@ paths:
10541090
type: string
10551091
example: "5531997853327"
10561092
options:
1093+
externalAttributes: <any> - optional
10571094
type: object
10581095
properties:
10591096
delay:

src/whatsapp/dto/sendMessage.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class Options {
4646
presence?: WAPresence;
4747
quotedMessageId?: number;
4848
messageId?: string;
49+
externalAttributes?: any;
4950
}
5051
class OptionsMessage {
5152
options: Options;

src/whatsapp/services/whatsapp.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,8 @@ export class WAStartupService {
13641364
messageSent.id = id;
13651365
}
13661366

1367+
messageSent['externalAttributes'] = options?.externalAttributes;
1368+
13671369
this.ws.send(this.instance.name, 'send.message', messageSent);
13681370
this.sendDataWebhook('sendMessage', messageSent).catch((error) =>
13691371
this.logger.error(error),

0 commit comments

Comments
 (0)