charaf_ed | 2019-05-22 20:41:23 UTC | #1
Hello,
I would like to know how to generate a PureCloud Data Action using this code below:
{
"filter": {
"type": "or",
"clauses": [
{
"type": "or",
"predicates": [
{
"type": "dimension",
"dimension": "queueId",
"operator": "matches",
"value": "b98fcf28-0905-4499-93d0-cee2025720d7"
}
]
}
]
},
"metrics": [
"oMemberUsers",
"oUserPresences"
]
}
Yours,
tim.smith | 2019-05-22 20:44:06 UTC | #2
You'll need to create a JSON schema that defines that information. See Add contracts to custom actions for integrations in the resource center.
charaf_ed | 2019-05-22 20:45:29 UTC | #3
https://jsonschema.net/ would that help in my case ?
tim.smith | 2019-05-22 20:49:53 UTC | #4
Yes, that's a commonly used tool to help design your JSON schema.
charaf_ed | 2019-05-22 20:54:33 UTC | #5
I copied/passed the result given by the tool JSON SChema Tool into my output contract but while validatiing and saving , I got an error.
anon28066628 | 2019-05-22 20:59:26 UTC | #6
Hi Charaf, the json schema site you posted is helpful, but some of the fields (like $id) need to be removed. Also ensure the version number is "-04". These references also might be helpful for the translation maps (JSONPath selectors for the webservice response) or escaping JSON templates for inclusion in the action configuration:
Tools for Testing and Practicing Data Actions http://jsonplaceholder.typicode.com https://www.mockable.io
Online Tools for Formatting Data Actions Contracts and Configuration ○ JSON Schema generator: https://jsonschema.net/#/editor ○ JSON escape / unescape tool: https://www.freeformatter.com/json-escape.html ○ JSONPath expression reference: http://goessner.net/articles/JsonPath/index.html ○ JSONPath expression evaluator: http://jsonpath.com
charaf_ed | 2019-05-22 21:04:03 UTC | #7
Thank you @anon28066628
Ok I'll try to remove all $id fields before and also modifying the version number.
Do you confirm that the changes will occur only in the output contract ? how about the input contract ?
Thank you for your help
charaf_ed | 2019-05-22 21:08:49 UTC | #8
{ "definitions": {}, "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "The Root Schema", "required": [ "filter", "metrics" ], "properties": { "filter": { "type": "object", "title": "The Filter Schema", "required": [ "type", "clauses" ], "properties": { "type": { "type": "string", "title": "The Type Schema", "default": "", "examples": [ "or" ], "pattern": "^(.)$" }, "clauses": { "type": "array", "title": "The Clauses Schema", "items": { "type": "object", "title": "The Items Schema", "required": [ "type", "predicates" ], "properties": { "type": { "type": "string", "title": "The Type Schema", "default": "", "examples": [ "or" ], "pattern": "^(.)$" }, "predicates": { "type": "array", "title": "The Predicates Schema", "items": { "type": "object", "title": "The Items Schema", "required": [ "type", "dimension", "operator", "value" ], "properties": { "type": { "type": "string", "title": "The Type Schema", "default": "", "examples": [ "dimension" ], "pattern": "^(.)$" }, "dimension": { "type": "string", "title": "The Dimension Schema", "default": "", "examples": [ "queueId" ], "pattern": "^(.)$" }, "operator": { "type": "string", "title": "The Operator Schema", "default": "", "examples": [ "matches" ], "pattern": "^(.)$" }, "value": { "type": "string", "title": "The Value Schema", "default": "", "examples": [ "b98fcf28-0905-4499-93d0-cee2025720d7" ], "pattern": "^(.)$" } } } } } } } } }, "metrics": { "type": "array", "title": "The Metrics Schema", "items": { "type": "string", "title": "The Items Schema", "default": "", "examples": [ "oMemberUsers", "oUserPresences" ], "pattern": "^(.*)$" } } } }
Should I remove also the *"pattern": "^(.)$"** ?
anon28066628 | 2019-05-22 21:09:47 UTC | #9
The contracts are of the same type (a JSON schema), so the same changes apply to both. That site btw is configurable - I usually uncheck / disable most of the options to get a very basic schema.
Some options like 'required' are useful though - especially if specific response fields are expected and required. It's helpful with using the Test feature and figuring out when your output schema doesn't line up with your response or translation map outputs (if explicitly required and missing, it will throw an informative schema validation error).
charaf_ed | 2019-05-22 21:19:39 UTC | #10
@anon28066628 I had less error than before by following your explanations
anon28066628 | 2019-05-23 13:30:15 UTC | #11
Hi Charaf, the output schema should be what your expect your action to output. Can you describe what you're trying to do?
In general the input schema should include the variable inputs to your query. For analytics, this is usually the interval string and (for example) a userId. Your input and output schemas are typically simple, for example:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": [ "interval", "userId" ], "properties": { "interval": { "type": "string" }, "userId": { "type": "string" } } }
This expects 2 inputs to the data action, both of which are required. The actual analytics request body is part of the request template. Most of the request body is usually static, with some placeholder template variables represented by ${input.xxxxxx}. These inputs come from your input schema.
system | 2019-06-23 13:30:19 UTC | #12
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5216