The directory link didn’t work for me butthis Add to Tana action is the only one I am aware of – added by Jason a year ago.
I have copied the API on the Inbox node but when I run the action on a test para in Drafts, it appears to run but doesn’t prompt for the API key as expected. Can’t see an alternative way to add it.
The action you mention does not have any logging. It’s likely the HTTP request is failing for some reason, but you would need to explicitly log that to see what’s going on. Add the below to the end of the script and any HTTP response errors will be in the action log:
const credential = Credential.create(
“tana”,
“Tana.inc\nPress cmd+k and select ‘Get API Token’ on your inbox node”
);
credential.addPasswordField(
“token”,
“Token”,
);
if (!credential.authorize()) {
alert(“No API token provided or found.”);
context.fail(
“Tana API token not entered, or not found. Clear API token and try again if no prompt was provided.”
);
}
I think the cut-and-paste must have stripped out the backticks. Here’s the action with your addition:
const credential = Credential.create(
“tana”,
“Tana.inc\nPress cmd+k and select ‘Get API Token’ on your inbox node”
);
credential.addPasswordField(
“token”,
“Token”,
);
if (!credential.authorize()) {
alert(“No API token provided or found.”);
context.fail(
“Tana API token not entered, or not found. Clear API token and try again if no prompt was provided.”
);
}
const credential = Credential.create(
“tana”,
“Tana.inc\nPress cmd+k and select ‘Get API Token’ on your inbox node”
);
credential.addPasswordField(
“token”,
“Token”,
);
if (!credential.authorize()) {
alert(“No API token provided or found.”);
context.fail(
“Tana API token not entered, or not found. Clear API token and try again if no prompt was provided.”
);
}
Note: If you use ``` to wrap code in the forum, it will be treated as a code block.
Here’s the complete version with the troubleshooting code where it needs to be. To be clear, I know nothing about Tana, I did also make a change to the endpoint URL (added V2) because that appears to be what they are publishing in their API docs now.
const credential = Credential.create(
"tana",
"Tana.inc\nPress cmd+k and select 'Get API Token' on your inbox node"
);
credential.addPasswordField(
"token",
"Token",
);
if (!credential.authorize()) {
alert("No API token provided or found.");
context.fail(
"Tana API token not entered, or not found. Clear API token and try again if no prompt was provided."
);
}
const content = encodeURI(draft.content);
const url = `https://europe-west1-tagr-prod.cloudfunctions.net/addToNodeV2?note=${content}`;
const http = HTTP.create();
const response = http.request({
"url": url,
"method": "GET",
"headers": {
"Authorization": `Bearer ${credential.getValue("token")}`,
"Content-Type": "application/json",
}
});
console.log(`${response.statusCode}, ${response.error}`)
console.log(response.responseText)
OK, I have created an inbox on my main workspace node. ‘Agile Tortoise’ has helpfully given me an extra couple of lines to add a log trace and work out what is going on,
I got got an API for the workspace. The action appears to have saved and the log confirms this — but the instruction…
Create a new draft and select this action. You will be prompted for the API key
… doesn’t tally with my experience: I have not been prompted for the API token, and nothing has appeared in the inbox.
Just had a similar issue, my issue is that it creates the Tana node but it is empty. The issue is as observed by agiletortoise (hi!!), Tana has published a new version of their API (v2) and wants everyone to use it. The “v1” that this action targets still does exist, and works but has some limitations that you may be observing. One is that it can’t ingest Drafts Markdown, if the url encoded “note” query param starts with a “#” (h1), the API will return a 200/OK but create only an empty node. Removing the “#” works as you might expect for V1. Anyway, this Action does need to be updated to use V2, as we don’t know how long V1 will continue to work.
I am trying to get this figured out for my system, there are some other issues here (around exporting to a specific node) and when I get them working I’ll report back in this thread if the fix is any different than what’s already posted. So we can get the Action updated.
Not sure Tana understands Markdown (yet…!) so I just feed it plain text. It’s not a great drawback as Tana’s great strength is gathering together various strands with its power of organisation through supertags. I take my edits to Obsidian or sometimes Ulysses for finalising and that’s where Markdown scores.
But I agree that this very useful action needs updating.
I’ve created a new Drafts Action to target the Tana Input API v2, and added some functionality to export a draft to different places in a Tana Workspace and to export to one or more than one destination node in Tana.
The directory is open to add to - you just add it if you think it could be of use to others and would like to share it. No need to seek any confirmation.