---
schema_version: "1"
id: d0744ff58bc28ee4e400142c9a2dfbf559c200f1e9583efae4559c0563f81bb9
title: Pass Custom Context Variables to the Bot
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/bot-api/einstein-bot/guides/sdk/sdk-basic-bot-client-pass-custom-context-variables.md
canonical_url: https://developer.salesforce.com/docs/service/einstein-bot-api/guide/sdk-basic-bot-client-pass-custom-context-variables.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 59433792af6cc8a5282518411b8bb62998e5ac1fe808d15e4bedea673aa43228
products:
  - Einstein Bots API and SDK
  - Enstein Bot API and SDK
---
# Pass Custom Context Variables to the Bot

With `variables` you can optionally pass custom context variables to the bot when initiating a bot session. See [What’s a Variable?](https://help.salesforce.com/s/articleView?id=service.bots_service_whats_a_variable.htm&type=5). Let’s say you want the bot to greet the customer with their name. First, configure a `CustomerName` context variable in the Bot Builder.

![Pass custom context variables to the bot](https://developer.salesforce.com/media/pass-custom-context-variables.png)

Then create a `variables` list and add the context variable with the value. Include this in the initial `BotSendMessageRequest()` object when you start the session.

```java
List<AnyVariable> variables = Collections
    .singletonList(new TextVariable()
        .name("CustomerName") // Context variableName
        .type(TypeEnum.TEXT)
        .value("Jane Doe")// Context variableValue
    );

BotSendMessageRequest botSendInitMessageRequest = BotRequest
    .withMessage(message)
    .variables(variables)
    .requestId(UUID.randomUUID().toString())
    .build();
```

You can then configure the greeting message to show the customer’s name. Here is the bot’s response message using the `CustomerName` context variable with the value “Jane Doe”.

```bash
Hi Jane Doe,
I’m a demo bot for the user guide.
Choose one of the options below
1.Order Status
2.Frequently Asked Questions
3.Transfer To Agent
4.End Chat
```
