Javascript SDK Reference

Reference documentation for the Javascript SDK

The canonical url for the current of the Javascript SDK is https://alcmeon.com/widget/1.0/sdk.js. This SDK defines a single object named alcmeon which defines the following attributes.

subscribe

Subscribe to notifications from the enclosing iframe.

Parameters

nametypedescription
callbackfunction callback(context)A callback that will be invoked with a single argument of type Context

Return value

There is no return value

See Also

The Context object reference: Context

Example usage

function handleContext(context) {
  console.log(context);
}

alcmeon.subscribe(handleContext);

getAgent

Return the Agent who opened the currently-open iframe. This function can be invoked ONLY from within the callback given to the subscribe function.

Parameters

None

Return value

A object of type Agent:

NameTypeDescription
idintegerA unique id associated with the agent.
namestringA human-readable string associated with the agent.
emailstringThe email associated with the agent's account.

Example usage

function handleContext(context) {
  agent = alcmeon.getAgent();
  console.log(agent.email);
}

alcmeon.subscribe(handleContext);

closeModal

Close the modal where the iframe hosting this code is inserted. Note: there is no expectation that this function should be invoked from within the context handler.

Parameters

None.

Return value

None.

Example usage

alcmeon.closeModal();