{ "kind": "open-flow-workflow", "version": 1, "name": "Create a Twist Channel and Send a Message", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_373dc8faaca1533c": { "name": "Enter Twist IDs", "kind": "start", "inputDefs": [ { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "workspaceId" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "conversationId" } ] }, "n_250dbf1eeafb7657": { "inputs": { "workspaceId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_373dc8faaca1533c", "output": "workspaceId" } ] }, "userId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_373dc8faaca1533c", "output": "userId" } ] } }, "name": "Prepare the channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "workspaceId" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "userId" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare the channel", "moduleId": "n_5f603d6fd9668380", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_5c1c642da505bb9e": { "inputs": { "url": { "kind": "value", "value": "https://api.twist.com/api/v3/channels/add" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_250dbf1eeafb7657", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Create the channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Create the channel", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_0c66478b91da77e0": { "inputs": { "channel": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_5c1c642da505bb9e", "output": "body" } ] } }, "name": "Prepare the description", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "channel" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ], "name": "Prepare the description", "moduleId": "n_b99253fb0ac5f19f", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_faceb041be78d6cb": { "inputs": { "url": { "kind": "value", "value": "https://api.twist.com/api/v3/channels/update" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0c66478b91da77e0", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Update the channel", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Update the channel", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_8659540f592cedd4": { "inputs": { "workspaceId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_373dc8faaca1533c", "output": "workspaceId" } ] }, "userId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_373dc8faaca1533c", "output": "userId" } ] }, "conversationId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_373dc8faaca1533c", "output": "conversationId" } ] }, "name": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_0c66478b91da77e0", "output": "name" } ] } }, "name": "Prepare the message", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "workspaceId" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "userId" }, { "jsonSchema": { "type": "integer", "minimum": 1 }, "nullable": false, "handle": "conversationId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "name" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" } ], "name": "Prepare the message", "moduleId": "n_2f9f8e1af32eddec", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_eac8d6f4550c8433": { "inputs": { "url": { "kind": "value", "value": "https://api.twist.com/api/v3/conversation_messages/add" }, "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_8659540f592cedd4", "output": "body" } ] }, "auth.token": { "kind": "unset" } }, "name": "Send the conversation message", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "url" }, { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "auth.token" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" } ], "name": "Send the conversation message", "executor": { "method": "POST", "query": { "mode": "fields", "names": [] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "json", "authentication": { "type": "bearer" }, "responseFormat": "json", "statusPolicy": "success", "kind": "http-request" } } }, "n_6f03bf3491b6d825": { "name": "Message response", "kind": "outputs", "outputDefs": [ { "jsonSchema": {}, "nullable": true, "handle": "response" } ], "outputMappings": { "response": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_eac8d6f4550c8433", "output": "body" } ] } } } }, "edges": [ { "source": "n_373dc8faaca1533c", "target": "n_250dbf1eeafb7657" }, { "source": "n_250dbf1eeafb7657", "target": "n_5c1c642da505bb9e" }, { "source": "n_5c1c642da505bb9e", "target": "n_0c66478b91da77e0" }, { "source": "n_0c66478b91da77e0", "target": "n_faceb041be78d6cb" }, { "source": "n_faceb041be78d6cb", "target": "n_8659540f592cedd4" }, { "source": "n_8659540f592cedd4", "target": "n_eac8d6f4550c8433" }, { "source": "n_eac8d6f4550c8433", "target": "n_6f03bf3491b6d825" } ] } }, "modules": { "n_5f603d6fd9668380": { "name": "Prepare the channel", "imports": [], "source": "export default function prepare({workspaceId,userId}){return{body:{workspace_id:workspaceId,name:'n8n-docs',user_ids:[userId]}}}\n" }, "n_b99253fb0ac5f19f": { "name": "Prepare the description", "imports": [], "source": "export default function update({channel}){if(!channel||typeof channel!=='object'||!Number.isSafeInteger(channel.id)||channel.id<=0||typeof channel.name!=='string'||!channel.name)throw Error('Twist did not return a channel ID and name');return{body:{id:channel.id,description:'Discussion for documentation'},name:channel.name}}\n" }, "n_2f9f8e1af32eddec": { "name": "Prepare the message", "imports": [], "source": "export default function message({workspaceId,userId,conversationId,name}){return{body:{conversation_id:conversationId,workspace_id:workspaceId,content:'Hey [Recipient](twist-mention://'+userId+')!\\nYou have been added to the '+name+' channel.\\nClick on the button below to quickly navigate to the documentation website.',actions:[{url:'https://docs.n8n.io',type:'action',action:'open_url',button_text:'Documentation site'}]}}}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }