Resources Module in Blip July 06, 2023 20:05 Updated Index: What is the Resources module for? How to access the Resources module Creating content Understanding routers within Blip Applications in the Resources module Codes Contents How to create configuration keys? Resources API What is the Resources module for? The Resources module allows you to create content for your chatbots, which can be easily used through the "resource" variable in your flow. How to access the Resources module To access it, you need to go to your chatbot or router and click on the menu […] > Contents > Resources: Creating content After accessing the module, you can add your content by clicking on the + Add New button and filling in the desired content: You will need to provide a Key; This key will be used in your flow whenever you want to use the content of this resource, so do not create long names with special characters. Stick to using only letters. One suggestion is to use camelCase. Then, select the type of content you are creating. There is a list with various types available using Blip's components, but the main ones are JSON and Text. With these two types, you will be able to add any content. Finally, you need to add your content according to the previously selected type. Here is an example of resources with JSON content: Once a resource is created, it can be accessed by one or multiple chatbots depending on the structure of your chatbot. The Resources feature becomes powerful when combined with a router structure and multiple subbots because you can access the content of your resources in any of the subbots. Understanding routers within Blip You can also have a router structure but not share resources between subbots. It all depends on the structure of your chatbot. Why does it depend so much on the structure of my chatbot? To explain better, let's illustrate some possible scenarios combining the structure with resources: 1º Scenario: Note that in this example, there is a resource called "name" in both the router and the subbot. Due to the router context being enabled in the subbots, the resource from the router will prevail. 2º Scenario: In this scenario, the only difference from the first scenario is that the router context is now disabled. Even though the router has a resource called "name", the resource from the subbot will prevail. In both of the first two scenarios, the following factors will control the displayed content: Where you added the resource Whether the router context is enabled or disabled in the subbots. In this structure, you could also have one of the three subbots with the router context disabled, while the other two have it enabled. 3º Scenario: In this scenario, we have 2 routers connected to the same subbots. This allows you to make your solution scalable, enabling multiple channels to be connected in a single subbot structure. In this scenario, for the solution to become scalable, it is crucial to have the router context enabled in the subbots. The routers will always control the content. When you converse with WhatsApp connected to Router#1, you will receive the content registered in the resource of Router#1. If you converse with WhatsApp connected to Router#2, the content of Router#2 will be displayed... and so on for all the routers and channels connected to the structure. Applications in the Resources module As we've seen, the Resources module allows you to centralize the content of your chatbot, making maintenance more practical and efficient, and making it even more scalable. But let's learn how to use it in practice? Codes You can add this code in the Resources module and use it within your scripts. See how easy it is: function run() { var date = nowUTC(); var data = [formatDay(date.getUTCDate()), formatMonth(date.getUTCMonth()), date.getUTCFullYear()].join("/"); var hora = [formatDay(date.getUTCHours()), formatDay(date.getUTCMinutes()), formatDay(date.getUTCSeconds())].join(":"); return data + " " + hora;}function nowUTC() { let offset = -3; let now = new Date(); let utc_timestamp = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()); return new Date(utc_timestamp + offset * 3600 * 1000);}function formatDay(day) { return day < 10 ? `0${day}` : day;;}function formatMonth(month) { month = parseInt(month) + 1; return month < 10 ? `0${month}` : month;} Resource named "gen.dateTime" with a script that generates the date and time in Brazil (GMT-3) format. Using the gen.dateTime resource within a Script in the Flow. Contents Just like codes, your flow may have contents that need to be updated frequently, and using resources is highly recommended here. And when I say contents, I'm not just talking about text. It can also be media (image/video), a document, a menu, etc. A classic example is the name of the virtual assistant that I mentioned in the scenarios above, which changes according to each structure. How to create configuration keys? You can create configuration keys in your resources and dynamically create journeys, contents, and even menus. If you need to enable or disable any configuration, you just need to go to the resource. Here's an example: Flow configuration resources. Script for creating a dynamic menu based on configuration resources. Speaking of configurations, you can also use the resource in Exit Conditions: Exit condition based on configuration resources. Resources API Last but not least, you can check our Resources documentation by clicking here. There you will find more information about this module and learn how to create, edit, and read a bot resource through the API. For more information, visit the discussion on the subject in our community or the videos on our channel. 😃 Related articles Using Dynamic Content Sending WhatsApp Active Messages on Blip Desk How to configure Dialogflow as your AI provider Submitting data for analysis through Webhooks Dashboard - Conversational Flow