How do I use tokens?

Articles can have straightforward answers that answer the context of the question. For example:

  • Where is the cafeteria? can be answered with The cafeteria is located on the third floor. It is open from 5 AM to 11 PM.

  • When is the cafeteria open? can be answered with The cafeteria is open from 5 AM to 11 PM and is located on the third floor.

If you have many articles referencing the location and hours for the cafeteria, you can use tokens in the articles to save time and energy. If the information changes, you need only change the value of the token in the Content area.

A token pulls in data from a centralized content item. (Open the left menu and select Create > Components > Content.) In the following image, tokens are used for location and hours as follows:

  • Where is the cafeteria? can be answered with The cafeteria is located on {{msg.payload.hospitalData.cafeteriaLocation}}. It is open from {{msg.payload.hospitalData.hospitalHours}}.

  • When is the cafeteria open? can be answered with The cafeteria is open from {{msg.payload.hospitalData.hospitalHours}} and is located on {{msg.payload.hospitalData.cafeteriaLocation}}.

A developer or content author can reference variable values using tokens. However, a developer has to be involved in making those variable values available to the content from the Token drop-down menu on the Add Article dialog box. For developer information, see What is the msg object? Other tokens (sometimes called mustache variables for their use of curly braces {} ) are derived from the Content-type properties.

Related Articles