Knowledge Center next icon Guide to Context Variables
Apr 06, 2023
6 minutes read

Guide to Context Variables

Context toggle

This guide will help you set up context so that you can apply different answers to a group of questions.

Learn more about the following topics:

System Context Variables

Projects come with two standard System Context Variables:

  • DeviceOS (The operative system of the device that makes the request)
  • DeviceType (The type of device that makes the request)

Note: These System Context Variables cannot be edited and are always logged. You can view the values for these variables via the Editor.


blobblob

How to Create a New Context Variable

You can find the Context Variables Editor in the Configuration Menu. If you don't see this option available, you will need to request the user role Content Engineer from your project Admin to access this editor.

When using context, you’ll need to have a clear idea of how the context should work and what content it relates to.

Users with the role Content Engineer can create new context for their project via the context variables editor in the Configuration screen.

image.png

Steps

Before you start adding context variables, you should have a clear idea of how the context should work, and what type of content it will relate to in your project.

Follow these steps to create a new context variable:

  1. Click the add ‘+’ icon
  2. Fill in the Name – the first character must be a letter or an underscore and the name cannot contain a space
  3. Add a description – provide a clear and concise description of what the context is used for
  4. Add values - start adding the values for your context variable – the first character must be a letter or an underscore and the value cannot contain a space. The rest can include any letter, number or an underscore
  5. Once you have added all the values for your new context variable, click save

5185-cm-create-context.gif

Once your new context variable has been saved in the Editor, it will already be available via the output editor and can be added to your answers.

Note: Depending on how the context is intended to work, you might need your Developer to apply additional logic to implement the context.

You can also edit existing context variables in your project. It’s important to know that if you edit the Name or Values of an existing context variable, you should check with your Developer first to make sure you won’t be breaking any of the logic built behind the context variable.

Additionally, any time you add a new value to an existing context variable, you should also inform your Developer so that they can adjust the logic if necessary.

How to Add Context to Answers

Context can be applied to the answers in your articles, dialogs, and events.

Articles always contain 1 default answer, noticeable by the purple "A". This is the standard answer given to the article when there are:

a. no contextual answers applied
b. context was applied to the article, but none of the context is applicable to the end user asking the question.

Default Answer:

image.png

Contextual Answer:

image.png

Steps

Follow these steps to add a contextual answer:

  1. Find the article that you want to add a contextual answer to
  2. Type a new answer in the answer editing field and click the "Add answer" button. You now have an answer marked with a grey "A"
  3. Click on the "Context variables / Metadata" button to see the list of available contexts
  4. Find the context you want to use and select it
  5. Scroll to the top of the article and click "Save"

add context.gif

💡Good to know: Your article can contain multiple answers with different contexts applied and you can also combine multiple contexts to one answer.

New projects come with some standard system contexts (i.e. DeviceType and DeviceOS). Other types of context need to be added via the Configuration screen first. Then you can apply them to your answers.

How to Test Contextual Answers

Steps

In Test, when you click on "Click to set context", you can select the context from the list that you want to test with.

Once the context has been applied, ask a question.

If you haven't specified a context for the question you typed, the answer you receive will be the default answer.

When everything works properly, you will receive the answer with the applied context. If it doesn't work, you might want to check the following:

  • The correct question was asked
  • The (correct) context was applied in the Test screen
  • The (correct) context was applied to the answer in the article

test context.gif

To remove the context value from the test screen, simply click the 'x' on the context value

image.png

Context Maintenance

As with any regular article answer, you should check your contextual answers periodically to make sure they are performing well and the information provided is still relevant and helpful to your customers.

Use the Dashboards and apply the filter "Context Value" to see specific data for each context. Is the context working as you expect it to? Are there any interactions with this context? Are the answers still relevant and up-to-date? How’s the feedback?

Investigate any issues you encounter and make improvements where needed.

Note: Context values will only be logged in the dashboards if they were relevant for an answer. In some cases, certain contexts can be marked to always be available in the dashboards. To enable this, you’ll need to send a ticket to Conversational AI Cloud Support.

Can I apply multiple context to one answer?

It is possible to add multiple context to one answer.

One simple example would be to have a contextual answer for users who are logged in to their account on their smartphone. Just keep in mind, depending on how the context is intended to work, you might need your Developer to apply some additional logic.

What Is Context Value "Any"?

Default answers always have the value "any". However, this only becomes visible in your downloads when you have added a contextual answer. So if an article has contextual answers, there will be an "any" context on default answers.

If you see the context "any" when you don't have any contextual answers on your article this is likely because there was previously a contextual answer attached to that article which was since removed leaving only a default answer.

If you have an article with only a default answer, you can edit the article to remove the "any" context value.

group icon
Get support

Can’t find the answer you are looking for?
Ask for the help of our chatbot, or get in touch with our support team.

Contact Support
Is this region a better fit for you?
Go
close icon