> For the complete documentation index, see [llms.txt](https://docs.rapidbott.com/help-center/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rapidbott.com/help-center/artificial-intelligencs/x.ai-integration.md).

# X.AI Integration

### [XAI Integration](https://x.ai/)

The [XAI](https://x.ai/) integration empowers your Rapidbott chatbot with dynamic AI capabilities, enabling personalized, context-aware responses and advanced automation.&#x20;

#### **Step 1: Create Your XAI API Key** <a href="#step-1-create-your-inlinecard-api-key" id="step-1-create-your-inlinecard-api-key"></a>

To start using the **XAI** integration, you first need to create an API key. In your browser navigate to the **XAI** platform and within your account you can follow the instructions in the image below to generate your unique API key.

<figure><img src="/files/A2aNBw9EWws4VQDY41Tk" alt=""><figcaption></figcaption></figure>

**Step 2: Copy Your API Key and Wait for Provisioning**

Once you’ve generated the API key, copy it and wait until the provisioning process is completed. This may take a few moments. Ensure that the status indicates the key is ready to use before proceeding.

<figure><img src="/files/PjpPXhDbNirTWPylGoPE" alt=""><figcaption></figcaption></figure>

**Step 3: Configure the API Key in Rapidbott**

* Go to the **Integrations** section in your Rapidbott dashboard.
* Navigate to **XAI** and paste the copied **API key** into the designated field.
* Click **Save** and confirm that the status changes to “Verified.”

Once verified, you’re all set to start using **XAI** in your chatbot flows.

<figure><img src="/files/afv0dlMmGApdiR3rk95E" alt=""><figcaption></figcaption></figure>

**Using XAI in Your Flows**

To incorporate **XAI** in your chatbot workflows:

1. Open your bot in **Rapidbott**.
2. Navigate to an **Action Node** in your flow.
3. Select **Integrations** and choose.

<figure><img src="/files/ao6GrHc4n7DnF4PXOdnT" alt=""><figcaption></figcaption></figure>

From here, you can configure the **XAI** integration to perform various actions, including Chat Completions.

<figure><img src="/files/BLtthhLmensNmAYyn9Q3" alt=""><figcaption></figcaption></figure>

#### **Key Features and Configuration Options** <a href="#key-features-and-configuration-options" id="key-features-and-configuration-options"></a>

**Chat Completion**

This feature allows you to interact with **XAI** to generate dynamic responses for user interactions. Below are the configuration fields and their descriptions:

**Input Parameters**

&#x20;

&#x20;

**System Message:**\
This optional field provides context about your business or bot. For example, if you're creating a restaurant chatbot you can use something similar to this:\
`System: You are a Rapidbott steak restaurant helpful assistant. You will handle customer support, guide users, and book reservations. The restaurant operates from 9 am to 8 pm Monday to Saturday. No pets are allowed. Always offer the coupon code if applicable.`

* This helps the AI generate responses aligned with your business rules.

**Message:**\
This is the main user input or prompt for which you want the AI to generate a response. For example:\
`User: How I can make a reservation?`&#x20;

* You can use the system field `{{last_text_input}}` to dynamically pass user input.

<figure><img src="/files/RZC1oi1mHSILKaJeA6QG" alt=""><figcaption></figcaption></figure>

**System JSON Field ({{XAi}}):**\
This field tracks the entire conversation history, including system setup and user interactions. The JSON is limited to 20,000 characters. Older entries will be deleted once this limit is reached.

<figure><img src="/files/TuW63E9kRXILb6CDv9ou" alt=""><figcaption></figcaption></figure>

**Model**

Select the AI model to use. By default, the system uses **grok-beta**.

**Max Tokens**

Limits the number of tokens consumed during a task. This is useful for controlling response length and token usage.

**Temperature**

Controls the randomness of responses.

* Higher values (e.g., 1.0) produce more creative answers.
* Lower values (e.g., 0.2) result in more deterministic answers.

**Presence Penalty**

Encourages the AI to generate unique phrases. Higher values reduce repetition.

<figure><img src="/files/bix68q3bxUOrQVINdtnN" alt=""><figcaption></figcaption></figure>

**Frequency Penalty**

Controls how much to penalize new tokens based on their frequency in the text so far.

* **Default Value:** `0`
* **Behavior:**
  * A higher value discourages the AI from repeating lines or phrases verbatim.
  * A value of `0` allows responses to have natural repetitions.

**Recommendation:** Adjust this if you want less repetitive responses.

&#x20;

**Stop Sequences**

Defines up to 4 sequences where the AI will stop generating tokens.

**Number of Completions**

Specifies how many responses the AI should generate for a single prompt.

* **Default Value:** `1`
* **Caution:** Setting a higher value will consume more tokens and API quota.

Best used when you want multiple variations of the response for comparison.

**Example Usage:** Generate 3 options to pick the most suitable reply for a customer query.

<figure><img src="/files/49MCHKKyGCPsgYn9efax" alt=""><figcaption></figcaption></figure>

**Testing the Configuration**

1. Make a test request.
2. Map the assistant's response to a **Custom User Field** (e.g., a text field).
3. Save your configuration.

<figure><img src="/files/eG7FUv7iNllB3ZTCADLw" alt=""><figcaption></figcaption></figure>

**Sample Response:**

json

&#x20;

`{`

&#x20; `"id": "3b52aa21-8cba-4499-9732-2133d4bbe1f2",`

&#x20; `"object": "chat.completion",`

&#x20; `"created": 1732584765,`

&#x20; `"model": "grok-beta",`

&#x20; `"choices": [`

&#x20;   `{`

&#x20;     `"index": 0,`

&#x20;     `"message": {`

&#x20;       `"role": "assistant",`

&#x20;       `"content": "To make a reservation at our steak restaurant, please provide me with the following details: - Date and Time for your reservation - The number of people in your party - Your name - A contact number or email address for confirmation. Once I have this information, I can check availability and proceed with booking your reservation."`

&#x20;     `},`

&#x20;     `"finish_reason": "stop"`

&#x20;   `}`

&#x20; `],`

&#x20; `"usage": {`

&#x20;   `"prompt_tokens": 78,`

&#x20;   `"completion_tokens": 139,`

&#x20;   `"total_tokens": 217`

&#x20; `}`

`}`

&#x20;

&#x20;**Building a Chatbot Flow**

Once the **XAI** integration is configured, you can build advanced chatbot flows. For example:

1. Add a **Text Question Node** to send the **XAI** response and capture the user input.

<figure><img src="/files/sItORUwW6PYoDUW4eKLc" alt=""><figcaption></figcaption></figure>

2. Use the `</>` symbol to search for the Custom User Field that stores the **XAI** response.

<figure><img src="/files/j3QwUHhR7ZdKvPzBOTjX" alt=""><figcaption></figcaption></figure>

This flow is an example of a simple flow that can be used as a standard response. You can use your creativity to create flows according to your use case:

<figure><img src="/files/vwCGlfDAEMOcDRfplX9X" alt=""><figcaption></figcaption></figure>

#### **Creative Use Cases** <a href="#creative-use-cases" id="creative-use-cases"></a>

This integration can be tailored to your business needs. For instance:

* Automating restaurant bookings.
* Answering FAQs with dynamic, context-aware responses.
* Offering personalized recommendations based on user input.

By leveraging **XAI’s** capabilities, you can build efficient, intuitive, and highly responsive chatbot experiences for your users.
