Contentful
The Contentful example solution showcases how you can connect your Teneo bot with a content management system built in the platform Contentful. The solution contains an integration with Contentful and an example flow that showcases how data is accessed from the content model.
Solution contents
Contentful Integration
The solution contains a Content backend integration in the form of a class ContentfulHelper with the following methods:
- Get Product Names
- Get Product Info
The methods make use of a class called ContentfulHelper. You can find the ContentfulHelper.groovy file with the source code in the resource file manager of the solution. This allows you to easily modify or extend the class if needed.
Cosine Fuzzy Matcher
The solution makes use of a Cosine fuzzy matcher to identify product names in user inputs by comparing them to a products list dynamically populated from the CMS. You can find more information about the Cosine fuzzy matcher here: Cosine Similiarity.
Solution Overview
Prerequisites
This example makes use of the Contentful Product Catalogue Example app. You can create your own content model based on this example by selecting 'Create Space', choose to create from an example space and select the product catalogue example.
To be able to interact with the Contentful API your 'Space ID' and 'Access Token' need to be stored in the solution under the global variables contentfulSpaceId
and contentfulAccessToken
, respectively.
Add Credentials to your solution
Variable Name | Location |
---|---|
contentfulSpaceId | To locate your 'Space ID', navigate to the space you want to find the ID of. Click on the 'Settings' tab > 'Space Settings' > 'General settings'. On the 'Space Settings' page, you will see the 'Space ID' under the 'General section'. |
contentfulAccessToken | To generate an access token, open the space that you want to access (the top left corner lists all spaces), and navigate to the 'Settings' > 'API keys'. Select the 'API keys' option and create your first token. |
contentfulEnvironmentId | You will also need to supply the environment ID 'contentfulEnvironmentId' of your space. You can locate this under 'Space Settings' > 'Environments'. If you are starting from a new space this value will most likely be 'master'. |
Try it Out
After you have added the details above, you can try it out as follows:
User: product info streamliner classic car
Bot: A classic Playsam design, the Streamliner Classic Car has been selected as Swedish Design Classic by the Swedish National Museum for its inventive style and sleek surface. It's no wonder that this wooden car has also been a long-standing favorite for children both big and small! The Playsam Streamliner Classic Car, Espresso costs 44 dollars and can be purchased athttps://www.amazon.com/dp/B001xxxxx/
. There are currently 56 items in stock.
How does it work?
The Global Begin Dialog script calls the backend integration method 'Get Product Names' to dynamically populate the global map variable 'contenfulProductNames' with the name of each product in the catalogue and its corresponding entry id in the CMS. When the user enters an input, the cosine fuzzy matcher compares the textual similarity of the input to the list of product names in the product catalogue.
When a fuzzy match is confirmed, the flow calls the integration method get 'Product Info', which collects the fields productDescription, price, quantity and website from the content model. This data is stored in a map variable and then formatted to be displayed to the user in the output node.
Download
- Download the solution from the following link: Contentful.
- Import the solution into Teneo. For more details see: How to import solutions.