Context, and passing values in and out of plugin

Life has made it so that I need to delve into plug in creation.the best tutorial I found on it is the Copilot one, but their site went down half way through my course. Part of this may be that I dont know javascript (I do know python) I have three basic questions:

  1. how does data get into the plug in
  2. how does data get out of the plug in
  3. how do I access things in property and context?

The strange part is that I think I know the answers to these as I have just spent hours looking all over the forum and internet for answers. So here we go.

Getting data into the plugin.
I should be able to use the context object to get at the shared resource keys. so I have phone number and password as an example:

this works as it shows up in bubble when you use the plugin

So I THINK I should be able to have access to those fields via the context object.


But alas, this doesn’t work, when I run this action in a simple page:
image

I don’t understand why that doesn’t work. I have also tried to access it with:

var phone=context.keys.PhoneNumber;
var pw=context.keys.Password;

but that didn’t work either

I THINK I get data from the workflow via properties in a similar way, but since the above didn’t work I don’t have a strong feeling I am doing that right either.

Getting data out of a plugin into the workflow
I have seen two ways. Are either or both of these correct?

instance.publishState("KlokePlatformKey",  jsonData.access_token.token);

return {"KlokePlatformKey": jsonData.access_token.token};

I want the workflow to produce a key:value that can be used by the next item in the workflow. Like when it says “Result of Step 1” or to be able to use the output of the function to assign to a thing attribute.

Accessing things inside the property or context objects
Do I have the correct format above? Also, is there a way to see what is in those objects while the code is executing so I can see if the objects are getting the correct values in them, or if I am simply not assigning them properly?

These keys are server side, you can only see them in a server side action.

Well I moved the action to server side and now the phoneNumber and PW don’t show up at all. and its giving me an error on the formdata part, which means it skipped over the assignment of the context keys. Sooooo… I have no idea if this is better or worse

also, what is this? I never declared that i needed that resource.