From 9f642ffe99f4be4b1266096f0639163dda7e80bc Mon Sep 17 00:00:00 2001 From: Troy Taylor <44444967+troystaylor@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:40:11 -0500 Subject: [PATCH] Byword (Independent Publisher) (#2964) * Revert "Merge branch 'microsoft:dev' into dev" This reverts commit 096a7c31993f909c3ee2ccacb4d6a206a1a2b2a3, reversing changes made to cb0948670feda35e9fc2a43241de68bc50e06812. * Revert "Merge branch 'microsoft:dev' into dev" This reverts commit cb0948670feda35e9fc2a43241de68bc50e06812, reversing changes made to dc26e8a0268f26bc2f38bf3a66e8c90e98df9404. * Revert "Revert "Merge branch 'microsoft:dev' into dev"" This reverts commit 01764d0a6d9e3afa849a6a4159d751aee6108580. * Revert "Revert "Merge branch 'microsoft:dev' into dev"" This reverts commit a3f086ef0f4e8b47ec14e9287ec7ebc29a09ea33. * Add files via upload * Revert "Add files via upload" This reverts commit eeff7b7a02a5c65406413e7c848ebc718c30183e. * Add files via upload * Delete independent-publisher-connectors/FileIO directory * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Revert "Add files via upload" This reverts commit 1d855069580b1ee4670c7c8e3b2edec4e0d63cd5. * Update readme.md * Revert "Update readme.md" This reverts commit b94447a14268a503fa5224ab942d8bbbdf443111. * Add files via upload --- .../Byword/apiDefinition.swagger.json | 366 ++++++++++++++++++ .../Byword/apiProperties.json | 35 ++ .../Byword/readme.md | 21 + .../Byword/script.csx | 41 ++ 4 files changed, 463 insertions(+) create mode 100644 independent-publisher-connectors/Byword/apiDefinition.swagger.json create mode 100644 independent-publisher-connectors/Byword/apiProperties.json create mode 100644 independent-publisher-connectors/Byword/readme.md create mode 100644 independent-publisher-connectors/Byword/script.csx diff --git a/independent-publisher-connectors/Byword/apiDefinition.swagger.json b/independent-publisher-connectors/Byword/apiDefinition.swagger.json new file mode 100644 index 000000000..b5c6092bf --- /dev/null +++ b/independent-publisher-connectors/Byword/apiDefinition.swagger.json @@ -0,0 +1,366 @@ +{ + "swagger": "2.0", + "info": { + "title": "Byword", + "description": "Generate high quality, AI-written articles at scale. Trusted by over 30,000 marketers, Byword has written hundreds of thousands of articles, on every topic imaginable.", + "version": "1.0", + "contact": { + "name": "Troy Taylor", + "url": "https://www.hitachisolutions.com", + "email": "ttaylor@hitachisolutions.com" + } + + }, + "host": "api.byword.ai", + "basePath": "/", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/create_article": { + "post": { + "responses": { + "200": { + "description": "default", + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "The message.", + "title": "Message" + }, + "articleID": { + "type": "string", + "description": "The article identifier.", + "title": "Article ID" + } + } + } + } + }, + "summary": "Create article", + "description": "Creates a new article from one of the three creation modes.", + "operationId": "ArticlePost", + "parameters": [ + { + "name": "body", + "in": "body", + "required": false, + "schema": { + "type": "object", + "properties": { + "mode": { + "type": "string", + "description": "The mode.", + "title": "Mode", + "default": "keyword", + "enum": [ + "keyword", + "title" + ] + }, + "input": { + "type": "string", + "description": "The input.", + "title": "Input" + }, + "language": { + "type": "string", + "description": "The language.", + "title": "Language" + }, + "subheadings": { + "type": "string", + "description": "The subheadings.", + "title": "Subheadings" + }, + "undetectable": { + "type": "boolean", + "description": "Whether undetectable.", + "title": "Undetectable" + }, + "tone": { + "type": "string", + "description": "The tone.", + "title": "Tone" + }, + "length": { + "type": "integer", + "format": "int32", + "description": "The length.", + "title": "Length" + } + }, + "required": [ + "input", + "mode" + ] + } + } + ] + } + }, + "/get_article": { + "post": { + "responses": { + "200": { + "description": "default", + "schema": { + "type": "object", + "properties": { + "Body": { + "type": "string", + "description": "The body.", + "title": "Body" + }, + "Body (Markdown)": { + "type": "string", + "description": "The body in markdown.", + "title": "Body (Markdown)" + }, + "Body (Plaintext)": { + "type": "string", + "description": "The body in plaintext.", + "title": "Body (Plaintext)" + }, + "Created Date": { + "type": "string", + "description": "The created date.", + "title": "Created Date" + }, + "Headings": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The headings.", + "title": "Headings" + }, + "Image - Assets": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The image assets.", + "title": "Image Assets" + }, + "Language": { + "type": "string", + "description": "The language.", + "title": "Language" + }, + "Meta": { + "type": "string", + "description": "The meta.", + "title": "Meta" + }, + "Mode": { + "type": "string", + "description": "The mode.", + "title": "Mode" + }, + "Source": { + "type": "string", + "description": "The source.", + "title": "Source" + }, + "Status": { + "type": "string", + "description": "The status.", + "title": "Status" + }, + "Table of Contents": { + "type": "string", + "description": "The table of contents.", + "title": "Table of Contents" + }, + "Title": { + "type": "string", + "description": "The title.", + "title": "Title" + }, + "URL Slug": { + "type": "string", + "description": "The URL slug.", + "title": "URL Slug" + }, + "_id": { + "type": "string", + "description": "The identifier.", + "title": "ID" + } + } + } + } + }, + "summary": "Get article", + "description": "Retrieve a created article. Articles typically take around 60 seconds to generate.", + "operationId": "ArticleGetPost", + "parameters": [ + { + "name": "body", + "in": "body", + "required": false, + "schema": { + "type": "object", + "properties": { + "articleID": { + "type": "string", + "description": "The article identifier.", + "title": "Article ID" + } + } + } + } + ] + } + }, + "/list_articles": { + "post": { + "responses": { + "200": { + "description": "default", + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Body": { + "type": "string", + "description": "The body.", + "title": "Body" + }, + "Body (Markdown)": { + "type": "string", + "description": "The body in markdown.", + "title": "Body (Markdown)" + }, + "Body (Plaintext)": { + "type": "string", + "description": "The body in plaintext.", + "title": "Body (Plaintext)" + }, + "Created Date": { + "type": "string", + "description": "The created date.", + "title": "Created Date" + }, + "Headings": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The headings.", + "title": "Headings" + }, + "Image - Assets": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The image assets.", + "title": "Image Assets" + }, + "Language": { + "type": "string", + "description": "The language.", + "title": "Language" + }, + "Meta": { + "type": "string", + "description": "The meta.", + "title": "Meta" + }, + "Mode": { + "type": "string", + "description": "The mode.", + "title": "Mode" + }, + "Source": { + "type": "string", + "description": "The source.", + "title": "Source" + }, + "Status": { + "type": "string", + "description": "The status.", + "title": "Status" + }, + "Table of Contents": { + "type": "string", + "description": "The table of contents.", + "title": "Table of Contents" + }, + "Title": { + "type": "string", + "description": "The title.", + "title": "Title" + }, + "URL Slug": { + "type": "string", + "description": "The URL slug.", + "title": "URL Slug" + }, + "_id": { + "type": "string", + "description": "The identifier.", + "title": "ID" + } + } + } + } + } + }, + "summary": "List articles", + "description": "Retrieves all articles created.", + "operationId": "ArticlesPost", + "parameters": [ + { + "name": "body", + "in": "body", + "required": false, + "schema": { + "type": "object", + "properties": { + "cursor": { + "type": "integer", + "format": "int32", + "description": "The cursor.", + "title": "Cursor", + "default": 0 + } + } + } + } + ] + } + } + }, + "definitions": {}, + "parameters": {}, + "responses": {}, + "securityDefinitions": {}, + "security": [], + "tags": [], + "x-ms-connector-metadata": [ + { + "propertyName": "Website", + "propertyValue": "https://byword.ai/" + }, + { + "propertyName": "Privacy policy", + "propertyValue": "https://byword.ai/" + }, + { + "propertyName": "Categories", + "propertyValue": "AI" + } + ] +} \ No newline at end of file diff --git a/independent-publisher-connectors/Byword/apiProperties.json b/independent-publisher-connectors/Byword/apiProperties.json new file mode 100644 index 000000000..4da8e9d54 --- /dev/null +++ b/independent-publisher-connectors/Byword/apiProperties.json @@ -0,0 +1,35 @@ +{ + "properties": { + "connectionParameters": { + "key": { + "type": "securestring", + "uiDefinition": { + "displayName": "API Key", + "description": "The API Key for this api", + "tooltip": "Provide your API Key", + "constraints": { + "tabIndex": 2, + "clearText": false, + "required": "true" + } + } + } + }, + "iconBrandColor": "#da3b01", + "scriptOperations": [], + "capabilities": [], + "policyTemplateInstances": [ + { + "templateId": "setqueryparameter", + "title": "Add API Key", + "parameters": { + "x-ms-apimTemplateParameter.name": "key", + "x-ms-apimTemplateParameter.value": "@connectionParameters('key')", + "x-ms-apimTemplateParameter.existsAction": "override" + } + } + ], + "publisher": "Troy Taylor", + "stackOwner": "Byword" + } +} \ No newline at end of file diff --git a/independent-publisher-connectors/Byword/readme.md b/independent-publisher-connectors/Byword/readme.md new file mode 100644 index 000000000..7b219fad7 --- /dev/null +++ b/independent-publisher-connectors/Byword/readme.md @@ -0,0 +1,21 @@ +# Byword +Generate high quality, AI-written articles at scale. Trusted by over 30,000 marketers, Byword has written hundreds of thousands of articles, on every topic imaginable. + +## Publisher: Troy Taylor, Hitachi Solutions + +## Prerequisites +You will need to sign up for an account with [Byword](https://byword.ai/signup). + +## Obtaining Credentials +You can find your API key on the [Integrations page](https://byword.ai/integrations_api). + +## Supported Operations +### Create article +Creates a new article from one of the three creation modes. +### Get article +Retrieve a created article. Articles typically take around 60 seconds to generate. +### List articles +Retrieves all articles created. + +## Known Issues and Limitations +There are no known issues at this time. diff --git a/independent-publisher-connectors/Byword/script.csx b/independent-publisher-connectors/Byword/script.csx new file mode 100644 index 000000000..e06633d32 --- /dev/null +++ b/independent-publisher-connectors/Byword/script.csx @@ -0,0 +1,41 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +public class Script : ScriptBase +{ + public override async Task ExecuteAsync() + { + var request = this.Context.Request; + var query = new Uri(request.RequestUri.AbsoluteUri).Query; + var queryParams = HttpUtility.ParseQueryString(query); + var key = queryParams["key"]; + + var requestBody = await request.Content.ReadAsStringAsync(); + var requestBodyDictionary = JsonConvert.DeserializeObject>(requestBody); + + var jsonObject = new Dictionary + { + { "key", key } + }; + + foreach (var kvp in requestBodyDictionary) + { + jsonObject[kvp.Key] = kvp.Value; + } + + var json = JsonConvert.SerializeObject(jsonObject); + var uriBuilder = new UriBuilder(request.RequestUri); + var queryParameters = HttpUtility.ParseQueryString(uriBuilder.Query); + queryParameters.Remove("key"); + uriBuilder.Query = queryParameters.ToString(); + var modifiedUri = uriBuilder.Uri; + + var modifiedRequest = new HttpRequestMessage(request.Method, modifiedUri) + { + Content = new StringContent(json, Encoding.UTF8, request.Content.Headers.ContentType.MediaType) + }; + + var response = await this.Context.SendAsync(modifiedRequest, this.CancellationToken).ConfigureAwait(false); + return response; + } +} \ No newline at end of file