Context

A context represents a partial state of Front that the user is interacting with.

Properties

PropertyTypeDescription
idStringID of the context. Will change with each update.
typeStringType of the context.
teammateTeammateThe teammate using the plugin.

Context type

There are different context types returned when the user is interacting with a sidebar plugin versus when a user is interacting with composer plugin. This topic explains the data model for each type of context below. To learn about the differences between composer and sidebar plugins at a more conceptual level, refer to the Overview topic.

Context types available when the user is viewing a sidebar plugin

For sidebar plugins, the context returns information about the conversations the user is interacting with from the normal Front workspace view.

  • noConversation when no conversation is selected by the user.
  • singleConversation when a single conversation is selected the user.
  • multiConversations when multiple conversations are selected by the user.

Properties within the sidebar plugin context types

The following table explains the additional properties available for the context types.

PropertyTypeDescriptionAvailable on Context types of:
conversationConversationThe conversation selected.singleConversation
conversationsArray of ConversationList of the selected conversations.multiConversations

Context types available when the user is viewing a composer plugin

For composer plugins, the context returns information about the conversation the user was interacting with when they clicked the composer plugin button in the composer toolbar.

  • messageComposer includes information about the conversation or the draft the user was interacting with when they clicked the composer plugin button in the composer toolbar.

Properties within the composer plugin context types

The following table explains the additional properties available for the context types.

PropertyTypeDescriptionAvailable on Context types of:
conversationConversationThe conversation selected.messageComposer
draftDraft messageThe current draft the user is composing.messageComposer

📘

Always check whether the conversation exists when creating a composer plugin

Composer plugins open in a modal when the user clicks the composer plugin button on the composer toolbar. The context for the composer plugin is set to the conversation the user had selected when they clicked the composer plugin button. This conversation is available as a context property called conversation.

However, there are times when the conversation will not exist:

  • When the user deselects the original conversation in Front.
  • When the user clicked the composer plugin button from a new unsaved draft.

In these cases, attempting to use methods normally available to the context (such as addLink) will trigger the error The draft's conversation is not selected. To avoid users interacting with buttons or links that will not work, you should check whether the conversation exists before offering the functionality to the user.