Action
Drafts to Mem.ai
Post draft to Mem.ai
Steps
-
script
/** ============================================================================ * DraftsToMem * * Send a draft to mem.ai * * @link https://docs.mem.ai/docs/ * * @version 1.0.0 * ========================================================================== */ const credential = Credential.create( 'Mem.ai', "To get an api key, visit the API Flow within the Mem app. From this page, you'll be able to generate a new API access token for yourself." ); credential.addPasswordField('apikey', 'API Key'); credential.authorize(); const apikey = credential.getValue('apikey'); if (!apikey) { context.fail('An api key is needed'); credential.addPasswordField('apikey', 'API Key'); credential.authorize(); } let draftcontent = draft.content; draftcontent = draftcontent.replace(/^(\s)*(-)(\s([^\n\r\t\0])*)$/gm, '$1*$3'); // change list type to Mem markdown const http = HTTP.create(); // create HTTP object const response = http.request({ // create the request url: 'https://api.mem.ai/v0/mems', method: 'POST', encoding: 'json', data: { content: draftcontent, }, headers: { Authorization: `ApiAccessToken ${apikey}`, 'Content-Type': 'application/json', }, }); if (response.success) { let success = JSON.parse(response.responseText); // Add the id and url from the response to the callback context.addSuccessParameter('id', success.id); context.addSuccessParameter('url', success.url); } else { const errorMsg = `${response.statusCode}: ${response.error}, ${response.responseText}`; context.fail(errorMsg); }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.