Skills Cards Metadata
Skills Cards Metadata
Once a processing service has determined the metadata for the file, your application can write that data back to the file stored on Box as metadata.
This process involves the following steps.
- Prepare the Skill Cards metadata
- Write the metadata to the file
Prepare Skill Cards metadata
The Skills metadata uses a globally available metadata template called
boxSkillsCards
. This template follows a specific format for the JSON
structure that will be stored on the associated files.
Box currently supports 4 kinds of cards.
Keyword | Displays a list of keywords next to the file. | |
Timeline | Displays a set of text/images, and when clicked shows when those images appear in a timeline. | |
Transcript | Displays a transcript with the corresponding timestamps. | |
Status | Displays a status to the user, which can be used to inform the user of the status of the Skill while it is processing the file. |
Write metadata cards to file
To write one or more cards to a file, you can use the POST /files/:id/metadata/global/boxSkillsCards
API and pass along a list of Box Skill cards
.
curl -X POST https://api.box.com/2.0/files/12345/metadata/global/boxSkillsCards \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"cards": [{
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}],
}'
const metadata = {
cards: [{
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}]
}
client.files.addMetadata('12345', 'global', 'boxSkillsCards', metadata)
.then(metadata => {
// ...
})
metadata = {
cards: [{
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}]
}
client.file(file_id='12345').metadata(scope='global', template='boxSkillsCards').create(metadata)
BoxFile file = new BoxFile(api, "12345");
Metadata metadata = new Metadata()
file.createMetadata("global", "boxSkillsCards", metadata);
var metadataValues = new Dictionary<string, object>()
{
cards: [{
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}]
};
Dictionary<string, object> metadata = await client.MetadataManager
.CreateFileMetadataAsync(fileId: "12345", metadataValues, "global", "boxSkillsCards");
Update metadata card on file
If Box Skill cards have already been applied to to a file then it can be updated
using the PUT /files/:id/metadata/global/boxSkillsCards
API. This API accepts a number of operations (op
) to perform, and each
operation can be used to replace a card at a position (path
).
curl -X PUT https://api.box.com/2.0/files/12345/metadata/global/boxSkillsCards \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Content-Type: application/json-patch+json' \
-d '[
"op": "replace",
"path": "/cards/0",
"value": {
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}
]'
const updates = [
{
'op': 'replace',
'path': '/cards/0',
'value': {
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}
}
]
client.files.updateMetadata('12345', 'global', 'boxSkillsCards', updates)
.then(metadata => {
// ...
})
file_metadata = client.file(file_id='12345').metadata(scope='global', template='boxSkillsCards')
card = {
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
}
updates = file_metadata.start_update()
updates.replace('/cards/0', card)
file_metadata.update(updates)
BoxFile file = new BoxFile(api, "12345");
Metadata metadata = new Metadata()
file.updateMetadata("global", "boxSkillsCards", metadata);
var card = new Dictionary<string, object>()
{
"type": "skill_card",
"skill_card_type": "keyword",
"skill_card_title": {
"code": "license-plates",
"message": "Licence Plates"
},
"skill": {
"type": "service"
"id": "license-plates-service"
},
"invocation": {
"type": "skill_invocation"
"id": "license-plates-service-123"
},
"entries": {
{ "text": "DD-26-YT" },
{ "text": "DN86 BOX" }
}
};
var updates = new List<BoxMetadataUpdate>()
{
new BoxMetadataUpdate()
{
Op = MetadataUpdateOp.replace,
Path = "/cards/0",
Value = card
}
};
Dictionary<string, object> updatedMetadata = await client.MetadataManager
.UpdateFileMetadataAsync("12345", updates, "global", "boxSkillsCards");