how to use output.integration.slack in Watson Assistant json response - json

I build a chatbot with Watson Assistant and integrate it with Slack. I want to write Native JSON supported by Slack through Watson Dialog using JSON Editor. The doc of Watson Assistant says:
output.integrations.slack: any JSON response you want to be included in the attachment field of a response intended for Slack.
(see https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-responses-json#dialog-responses-json-user-defined)
So I tried sth like this:
{
"output": {
"integrations": {
"slack": {
"attachment": {
"blocks": [
{
"text": {
"text": "Pick a date for the deadline.",
"type": "mrkdwn"
},
"type": "section",
"accessory": {
"type": "datepicker",
"action_id": "datepicker-action",
"placeholder": {
"text": "Select a date",
"type": "plain_text",
"emoji": true
},
"initial_date": "1990-04-28"
}
}
]
}
}
},
"generic": [
{
"response_type": "text",
"values": [],
"selection_policy": "sequential"
}
]
}
}
The content of the attachment field is copied from the Block Kit Builer(https://api.slack.com/tools/block-kit-builder).
But this seems not work. Can anyone give me some suggestions? Thanks in advance.

Output.integrations is not a preferred way.
Pls try
"output": {
"generic": [
{
"user_defined": {
//Put here your slack attachment
},
"response_type": "user_defined"
}
]}
By using user_defined you can mix with it more responses like text, image, etc.

Related

Autodesk Forge API - Patch Item Input Error

I am trying to use the PATCH projects/:project_id/items/:item_id endpoint in order to update the "displayName" attribute of an item in BIM360. There is an example on how to do exactly that in the Forge documentation, but for some reason I am getting an 400 error.
Here is my payload:
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "items",
"id": "ITEM_URN",
"attributes": {
"displayName": "NEW_ITEM_NAME.EXTENSION"
}
}
}
Here is the error I get:
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "a4c43bbb-9e34-4973-9f9c-58a7e1d7bdb6",
"status": "400",
"code": "BAD_INPUT",
"title": "One or more input values in the request were bad",
"detail": "Request input is invalid for this operation."
}
]
}
I successfully use the same endpoint in order to change the parent folder for this same item (as described in this post answer: Autodesk Forge; Pragmatically changing file location without new upload ), so the problem must be in the update "displayName" portion. Here the successful payload sample that returns a 200 answer:
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "items",
"id": "ITEM_URN",
"relationships": {
"parent": {
"data": {
"type": "folders",
"id": "DESTINATION_FOLDER_URN"
}
}
}
}
}
Forge Documentation with example: https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-items-item_id-PATCH/
What am I missing in order to update the "displayName" attribute?
If you want to change the file name, you can change tip version name and title , creating new version is required, but you don't have to upload file again. Please try the API at https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/ :
POST /versions?copyFrom={tip_version_urn}
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "versions",
"attributes": {
"name": "newName"
}
}
}
A new tip version will be created with the updated name.

How to add custom fields in google contacts API V3 with json

API Request
POST https://www.google.com/m8/feeds/contacts/default/full?alt=json
Body
{
"entry": {
"gd$name": {
"gd$fullName": {
"$t": "Rohit Roy"
},
"gd$givenName": {
"$t": "Rohit"
},
"gd$familyName": {
"$t": "Roy"
}
},
"gd$email": [
{
"address": "royrohit1234#exampledomain.com",
"primary": "true",
"rel": "http://schemas.google.com/g/2005#home"
}
],
"gd$phoneNumber": {
"$t": "+919999888877",
"primary": "true",
"rel": "http://schemas.google.com/g/2005#home"
},
"gd$organization": {
"gd$orgName": {
"$t": "XYZ Pvt. ltd."
}
}
}
}
This code is working properly i want to add custom fields to google contacts.
For that i tried convert below XML into JSON.
<gContact:userDefinedField key="chess" value="likes playing black"/>
Like This
"gContact$userDefinedField":{
"key":"food",
"value":"Chinese"
}
But this code is not working with above code so i need help to add custom field with my working code above.
Fortunately i got solution of custom fields, birthday and all other google contact fields with JSON API.
Google Contact API Docs updated and mentioned about Peoples API which is replacement of old google contact API.
So now i am using Peoples API instead of Contacts API V3 which already deprecated.
Click This Link For Peoples API Create Contact API Docs
HTTP Request
POST https://people.googleapis.com/v1/people:createContact
Body
{
"emailAddresses": [
{
"value": "rohitroy#exampledomain.com",
"type": "work"
}
],
"names": [{
"givenName": "John",
"familyName": "Doe"
}],
"birthdays": [
{
"date": {
"year": 1996,
"month": 5,
"day": 2
}
}
],
"userDefined": [
{
"key": "customfield",
"value": "anyvalue-123456"
}
]
}
In the Body userDefined is for custom fields.

Outlook Event API : At least one property failed validation error

I'm creating an Outlook event via Outlook API by providing following JSON input :
{
"subject":"bla bla bla",
"start":{
"dateTime":"2018-01-14T17:00:00",
"timeZone":"India Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "janets#a830edad9050849NDA1.onmicrosoft.com",
"Name": "Janet Schorr"
},
"Type": "Required"
}
]
}
However I'm getting the following error response :
{
"error": {
"code": "ErrorPropertyValidationFailure",
"message": "At least one property failed validation.",
"innerError": {
"request-id": "6f3d1676-77cc-49b0-87a2-b96b6ed1f15d",
"date": "2018-01-12T05:25:10"
}
}
}
If I pass the end attribute in the above JSON, the event is created successfully. The below JSON works fine :
{
"subject":"bla bla bla",
"start":{
"dateTime":"2018-01-14T17:00:00",
"timeZone":"India Standard Time"
},
"end":{
"dateTime":"2018-01-14T17:00:00",
"timeZone":"India Standard Time"
},
"Attendees": [
{
"EmailAddress": {
"Address": "janets#a830edad9050849NDA1.onmicrosoft.com",
"Name": "Janet Schorr"
},
"Type": "Required"
}
]
}
Is it required to pass an end attribute for event creation? Or is there something wrong with the above JSON input?
Yes, end is required. Outlook/Exchange don't support events with no end date :)

JSON file for google vision text detection

I want to detect chinese characters. So I follow google API to include the "languageHints" key. However, the request has problems and errors are returned. I am not sure whether I set the latLongRect and cropHintsParams correctly. Can anyone please help? Thank you very much.
{
"requests": [
{
"features": [
{
"type": "TEXT_DETECTION",
"maxResults": 10
},
{
"type": "DOCUMENT_TEXT_DETECTION",
"maxResults": 10
}
],
"image": { "content": "xxx"},
"imageContext": {
"latLongRect": {
"minLatLng": {
"latitude": "-180",
"longitude": "-90"
},
"maxLatLng": {
"latitude": "180",
"longitude": "90"
}
},
"languageHints": [
"zh*"
],
"cropHintsParams": {
"aspectRatios": [
"10"
]
}
}
}
]
}
json data shown above has syntax error and it is not well formed.
You can use any online json parser (for e.g. http://jsonparseronline.com/) to check if json is well-formed.
it will help if you can give details of error.

Jira rest api insert custom fields in create issue

I have following custom field. How do i pass it in JSON to create issue in jira using rest api
"customfield_10300":{
"required":false,
"schema":{
"type":"option",
"custom":"com.atlassian.jira.plugin.system.customfieldtypes:select",
"customId":10300
},
"name":"Severity",
"hasDefaultValue":false,
"operations":[
"set"
],
"allowedValues":[
{
"self":"http://sjira/rest/api/2/customFieldOption/10303",
"value":"Blocker",
"id":"10303"
},
{
"self":"http://sjira/rest/api/2/customFieldOption/10304",
"value":"Critical",
"id":"10304"
}
]
}
As the field is from type "select" you should use the JSON format to populate a select field:
Here an example:
{
"fields": {
"project":
{
"key": "PKEY"
},
"summary": "Your summary",
"description": "your description",
"issuetype": {
"name": "Task"
},
"customfield_10013": { "value": "Blocker" }
}
}
Some more details can be found here: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue