Skip to content

Instantly share code, notes, and snippets.

@swimmwatch
Created January 30, 2025 09:22
Show Gist options
  • Select an option

  • Save swimmwatch/4cec3ed514f77ca1ab6ecb96480cd965 to your computer and use it in GitHub Desktop.

Select an option

Save swimmwatch/4cec3ed514f77ca1ab6ecb96480cd965 to your computer and use it in GitHub Desktop.
ActivePieces flow for SRS
{
"created": "1738228226154",
"updated": "1738228226154",
"name": "Handle SRS update level",
"description": "",
"tags": [],
"pieces": [
"@activepieces/piece-notion",
"@activepieces/piece-openai",
"@activepieces/piece-telegram-bot"
],
"template": {
"displayName": "Handle SRS update level",
"trigger": {
"name": "trigger",
"valid": true,
"displayName": "Updated Topic",
"type": "PIECE_TRIGGER",
"settings": {
"pieceName": "@activepieces/piece-notion",
"pieceVersion": "~0.2.15",
"pieceType": "OFFICIAL",
"packageType": "REGISTRY",
"triggerName": "updated_database_item",
"input": {
"auth": "{{connections['notion']}}",
"database_id": "b4c40963-4298-4c10-b011-c3936e9497d2"
},
"inputUiInfo": {}
},
"nextAction": {
"name": "step_4",
"type": "CODE",
"valid": true,
"settings": {
"input": {
"is_repeated": "{{trigger['properties']['Repeated?']['checkbox']}}"
},
"sourceCode": {
"code": "export const code = async (inputs) => {\n return inputs.is_repeated;\n};",
"packageJson": "\n {\n \"dependencies\": {\n }\n }"
},
"inputUiInfo": {}
},
"nextAction": {
"name": "step_5",
"type": "BRANCH",
"valid": true,
"settings": {
"conditions": [
[
{
"operator": "BOOLEAN_IS_TRUE",
"firstValue": "{{step_4}}"
}
]
],
"inputUiInfo": {}
},
"displayName": "Branch",
"onSuccessAction": {
"name": "step_3",
"type": "PIECE",
"valid": true,
"settings": {
"input": {
"auth": "{{connections['notion']}}",
"database_id": "b4c40963-4298-4c10-b011-c3936e9497d2",
"databaseFields": {},
"database_item_id": "{{trigger['id']}}"
},
"pieceName": "@activepieces/piece-notion",
"pieceType": "OFFICIAL",
"actionName": "update_database_item",
"inputUiInfo": {},
"packageType": "REGISTRY",
"pieceVersion": "~0.2.15"
},
"nextAction": {
"name": "step_1",
"type": "CODE",
"valid": true,
"settings": {
"input": {
"is_repeated": "{{trigger['properties']['Repeated?']['checkbox']}}",
"current_level": "{{trigger['properties']['Level']['number']}}"
},
"sourceCode": {
"code": "export const code = async (inputs) => {\n if (inputs.is_repeated) {\n return inputs.current_level + 1;\n }\n\n return inputs.current_level;\n};",
"packageJson": "\n {\n \"dependencies\": {\n }\n }"
},
"inputUiInfo": {}
},
"nextAction": {
"name": "step_2",
"type": "PIECE",
"valid": true,
"settings": {
"input": {
"auth": "{{connections['notion']}}",
"database_id": "b4c40963-4298-4c10-b011-c3936e9497d2",
"databaseFields": {
"Level": "{{step_1}}",
"Repeated?": false
},
"database_item_id": "{{trigger['id']}}"
},
"pieceName": "@activepieces/piece-notion",
"pieceType": "OFFICIAL",
"actionName": "update_database_item",
"inputUiInfo": {},
"packageType": "REGISTRY",
"pieceVersion": "~0.2.15"
},
"nextAction": {
"name": "step_6",
"type": "PIECE",
"valid": true,
"settings": {
"input": {
"url": {
"url": "https://api.notion.com/v1/blocks/{{trigger['id']}}/children"
},
"auth": "{{connections['notion']}}",
"method": "GET",
"headers": {
"Notion-Version": "2022-06-28"
},
"failsafe": false,
"queryParams": {
"page_size": "100"
}
},
"pieceName": "@activepieces/piece-notion",
"pieceType": "OFFICIAL",
"actionName": "custom_api_call",
"inputUiInfo": {},
"packageType": "REGISTRY",
"pieceVersion": "~0.2.15",
"errorHandlingOptions": {
"retryOnFailure": {
"value": true
},
"continueOnFailure": {
"value": false
}
}
},
"nextAction": {
"name": "step_7",
"type": "CODE",
"valid": true,
"settings": {
"input": {
"notion_response": "{{step_6['body']}}"
},
"sourceCode": {
"code": "export const code = async (inputs) => {\n let body = inputs.notion_response;\n let results = body.results;\n let text = [];\n\n for (let block of results) {\n let type_ = block.type;\n let typeBlock = block[type_];\n\n let richTexts = typeBlock.rich_text;\n if (!richTexts) {\n continue;\n }\n let line = [];\n for (let richText of typeBlock.rich_text) {\n let content = richText.text.content;\n line.push(content);\n }\n text.push(line.join(' '));\n }\n\n return text.join('\\n');\n};",
"packageJson": "\n {\n \"dependencies\": {\n }\n }"
},
"inputUiInfo": {},
"errorHandlingOptions": {
"retryOnFailure": {
"value": false
},
"continueOnFailure": {
"value": true
}
}
},
"nextAction": {
"name": "step_8",
"type": "PIECE",
"valid": true,
"settings": {
"input": {
"auth": "{{connections['openai']}}",
"topP": "1",
"model": "gpt-3.5-turbo",
"roles": [
{
"role": "system",
"content": "You are a helpful assistant."
}
],
"prompt": "Придумай 3 вопроса и ответы к данному конспекту в формате HTML: {{step_7}}",
"maxTokens": "2048",
"temperature": "0.9",
"presencePenalty": "0.6",
"frequencyPenalty": "0"
},
"pieceName": "@activepieces/piece-openai",
"pieceType": "OFFICIAL",
"actionName": "ask_chatgpt",
"inputUiInfo": {},
"packageType": "REGISTRY",
"pieceVersion": "~0.3.26",
"errorHandlingOptions": {
"retryOnFailure": {
"value": false
},
"continueOnFailure": {
"value": false
}
}
},
"nextAction": {
"name": "step_9",
"type": "PIECE",
"valid": true,
"settings": {
"input": {
"auth": "{{connections['my-lms-bot']}}",
"format": "HTML",
"chat_id": "359774197",
"message": "{{step_8}}",
"web_page_preview": false
},
"pieceName": "@activepieces/piece-telegram-bot",
"pieceType": "OFFICIAL",
"actionName": "send_text_message",
"inputUiInfo": {},
"packageType": "REGISTRY",
"pieceVersion": "~0.3.14",
"errorHandlingOptions": {
"retryOnFailure": {
"value": false
},
"continueOnFailure": {
"value": false
}
}
},
"displayName": "Send questions and answers"
},
"displayName": "Ask ChatGPT"
},
"displayName": "Convert content to text"
},
"displayName": "Retrive content"
},
"displayName": "Update Level"
},
"displayName": "Increment level for repeated topic"
},
"displayName": "Remove Repeated checkbox"
}
},
"displayName": "Is repeated?"
}
},
"valid": true
},
"blogUrl": ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment