Channel-wide Metadata
Channel-wide Metadata is a JSON object which can be applied to all the trees in a Channel. This metadata can be a data source ID, API path for an advanced function or even a basic greeting response. You can edit the metadata in the "Tree Settings" of a "Channel".
You can make use of channel-wide metadata to improve the re-usability and reduce the channel deployment time of a tree build. For example, in the scenario where you are deploying a FAQ tree build to a new channel, you can keep the exact same tree build and simply change the data source ID in the new channel's metadata setting.
Expected Outcome
In the following example, the user applied different data source IDs in the Channel-wide Metadata for Facebook Messenger & WhatsApp. You can clearly spot out that the content are slightly different but the conversation flow is the same.
Getting Hands-On
You should decide which part of your chatbot build will be changed in different channels.
Locate that part of the chatbot build and apply
this.channel.metadata
accordingly. For example, if you want to use a different data source for a different channel, you can locate and replace all the original data source ID withthis.channel.metadata.faqDataSourceId
in thecollectionName
.
Example Pre-action
return new Promise(async (resolve, reject) => {
console.log("in Save Category 1 answers")
let result = await this.fetchDataFromDataSource({
channel: this.channel,
collectionName: this.channel.metadata.faqDataSourceId,
filter: {}
})
console.log("result", result)
result = this.lodash.uniqBy(result, "Category 1")
console.log("result", result)
result = this.lodash.reject(result, { "Category 1": "" })
console.log("result", result)
result = this.lodash.sortBy(result, "Category 1 Priority")
this.member.botMeta.tempData.currentAnswers = result.map(obj => obj["Category 1"])
this.member.botMeta.tempData.listLength = result.length
resolve({
member: this.member,
})
})
- Head to the specific channel and add the metadata JSON object to "Channel-wide Metadata" under "Tree Settings".
Below is a sample metadata object for FAQ data source:
{
"this.channel.metadata.faqDataSourceId": "5ea26a9d54dasd3dasd2_faq_level_5",
}
- For the text after
metadata.
you may designate any names to fit your use case. - For the string after
"this.channel.metadata.faqDataSourceId"
, you may input the actual data (e.g. data source ID or API path) to be applied in a specific channel.