In the Conversation API, it should be possible to create new entity with pattern values in either workspace creation phase (creat_workspace) or by invoking create_entity. They failed and return Error: Invalid Request Body, Code: 400. A feasible way is by creating the entity with only the name but no values and add entity value separately.
Request payload:
CreateEntity entities = [{
'entity': 'pattern_entity',
'values': [{
'value': 'value0', 'patterns': ['\\d{6}\\w{1}\\d{7}'], 'value_type': [patterns']
},
{'value': 'value1',
'patterns': ['[-9][0-9][0-9][0-9][0-9]~! [1-9][1-9][1-9][1-9][1-9][1-9]'],
'value_type': ['patterns']},
{'value': 'value2',
'patterns': ['[a-z-9]{17}'],
'value_type': ['patterns']},
{'value': 'value3',
'patterns': [
'\\d{3}(\\ |-)\\d{3}(\\ |-)\\d{4}',
'\\(\\d{3}\\)(\\ |-)\\d{3}(\\ |-)\\d{4}'],
'value_type': 'patterns'},
{'value': 'value4',
'patterns': ['\\b\\d{5}\\b'],
'value_type': ['patterns']}]
}]
This code works:
conv.create_entity(workspace_id=resp['workspace_id'], entity=entities['entity'])
for idx in range(len(entities['values'])):
conv.create_value(
workspace_id=resp['workspace_id'], entity=entities['entity'],
value=entities['values'][idx]['value'],
patterns=entities['values'][idx]['patterns'], value_type='patterns')
These don't work:
conv.create_entity(
workspace_id=resp['workspace_id'],
entity=entities['entity'], values=entities['values']
)
conversation.create_workspace(
name='API test',
description='Example workspace created via API',
entities=entities
)
In the Conversation API, it should be possible to create new entity with pattern values in either workspace creation phase (
creat_workspace) or by invokingcreate_entity. They failed and returnError: Invalid Request Body, Code: 400. A feasible way is by creating the entity with only the name but no values and add entity value separately.Request payload:
This code works:
These don't work: