Skip to main content

Send Message Controller

This specialized controller for sending different types of messages via WhatsApp, including text, link preview, media in general (images, videos, audios, documents), location and contacts. This controller offers a simple and efficient interface so that companies can dynamically and engagingly interact with their customers.

The Messaging Controller offers a complete set of features for companies to interact in a dynamic and personalized way with their customers on WhatsApp. With support for different types of content, our API makes interactions richer and more engaging, improving the customer experience and strengthening the relationship between companies and consumers.

Description of the externalAttributes Attribute

  1. Data Type: String.
  2. Content: Can contain representations of both simple and complex objects.
  3. Flexibility: No size restriction, allowing for a large amount of data to be included.
  4. Use: Can be utilized to transmit additional information that does not fit into other request fields.

Examples of Composition in Node.js

To compose the externalAttributes string, you can use JavaScript objects and then convert them into a JSON string. This allows for including complex data structures in the request.

Example 1: Simple Object

const externalAttributes = {
userId: 12345,
userName: "exampleUser",
preferences: {
theme: "dark",
language: "pt-BR"
}
};

const externalAttributesString = JSON.stringify(externalAttributes);

In this example, a simple JavaScript object is created with basic user properties and preferences. It is then converted into a JSON string.

Example 2: Complex Object

const externalAttributes = {
order: {
id: 67890,
items: [
{ productId: 111, quantity: 2 },
{ productId: 222, quantity: 3 }
],
shippingDetails: {
address: "Rua Exemplo, 123",
city: "São Paulo",
zipCode: "01234-567"
}
},
userComments: "Please deliver after 6 PM."
};

const externalAttributesString = JSON.stringify(externalAttributes);

In this example, a more complex object is used, representing an order with multiple items and shipping details, along with a user comment. The entire object is then converted into a JSON string.

Example 3: Simple String

const externalAttributesString = "Simple additional information";

Here, a simple string is used as the value for externalAttributes. This is useful for cases where a complex object is not necessary.