Using Dynamic Content November 18, 2022 18:00 Updated Index Using Dynamic Content Defining the content type Message Content Metadata Using Dynamic Content The Dynamic type is a type of message content that can be defined at runtime, that is, during the bot flow, allowing the content passed to the user to be built and displayed on demand and in a personalized way for each user. Via the Dynamic type is possible to build any of the other types of content programmatically and dynamically. For this, you need to know the structure of each one of them and fill in the content block as follows: MIME Type: Defining the content type This information will tell the block what it should expect to receive (an image, a menu, or a carousel, for example) and what it should display. These values can be found in the documentation for the type of content you want, found by clicking here. The main types can be found in the table below: Note: Be sure to check the content types supported by each channel to make sure the channel will be able to deliver the content you want. Message Content The message content is a JSON containing your information that will be displayed to the user in the bot. This JSON corresponds to the content object of the chosen content type structure and must follow the pattern. You can save this JSON in a variable and use it in this field. For example, if the desired content type is a Quick Reply, the JSON should have this pattern: Note: Don't forget to change the information so that it is displayed according to your needs. Metadata Use this field if you need to send some kind of extra information (metadata) to your bot, but it doesn't need to be displayed to the user. This information is passed in the format Key: value: Example: Slips list Let's say you have an API that returns a slip list for that specific customer according to some kind of information, such as CPF, for example. The JSON with the API response is structured in the following way: { "status":"ok", "results":[ { "titulo":"Pedido A - Parcela 1/12", "id": "ABTOASDLZ2224", "valor":"R$ 29.90", "vecto":"2020-06-11" }, { "titulo":"Pedido A - Parcela 2/12", "id": "ABTOASDLZ2225", "valor":"R$ 29.90", "vecto":"2020-07-10" }, { "titulo":"Pedido A - Parcela 3/12", "id": "ABTOASDLZ2226", "valor":"R$ 29.90", "vecto":"2020-08-10" }, { "titulo":"Pedido B - Parcela 1/5", "id": "APAXLDLZ7854", "valor":"R$ 69.90", "vecto":"2020-08-15" } ] } To display this response in a Text type content, like in the example below, it will be necessary to transform the response in order to adapt it to the standard required by the content. For this, it will be necessary to run a script, which separates each of the slips and transforms them into a single structure. For this example, the response from the API is saved in the response(1) variable. The structure created in this script, which will be used to fill the dynamic content, will be saved in the content(2) variable. function run(resposta) { var json = JSON.parse(resposta); var aux = ""; var count = 1; json.results.forEach(function (element) { aux = aux.concat(count, " - ", "Data: ", element.vecto, " valor: ", element.valor, "\n"); count++; }) return content; Since the Text content type expects a MIME Type of text/plain type, it will be placed in the dynamic content block settings. The content field will be filled with the content variable, generated in the javascript above. Example: Message Template with buttons in WhatsApp It is also possible to send a pre-approved Message Template on WhatsApp as a dynamic content during the bot flow. For this you need to create a Message Template and send it to WhatsApp for approval. If you want to know how to do this, click here. After approval of the Message Template, copy the Template name. On the bot, create a content of type Dynamic Content, fill in the Mime Type as application/json and the content value as shown below. { "type": "template", "template": { "name": "TEMPLATE_NAME", "language": { "policy": "deterministic", "code": "pt_BR" } } } For more information, access the discussion on the subject in our community or the videos on our channel. 😃 Related articles Creating interactive messages in WhatsApp How to Create and Approve a Message Template in WhatsApp Sending WhatsApp Active Messages on Blip Desk How to import a bot flow in Builder Active Messages - Error Codes