Variable Support in AI Chatbot (Hello Widget)

What does this feature do?
When someone chats on your website widget, their details (like name, email, mobile, or customer ID) are automatically passed securely in the background.

👉 The AI never sees these details directly.

👉 But when the chatbot needs to perform an action (like sending a message to Slack, creating a ticket, or updating CRM), these details are auto-filled at the last step to complete the task correctly.

This makes the chatbot smarter, faster, and more secure — without exposing private customer data.

🔄 How it Works (Simple Flow)

  1. Widget Loads – The Hello Chat Widget is added to your site with your customer variables (like user_id, email, etc.).

  2. User Chats – The customer types a query.

  3. AI Decides Action – The bot prepares an action (like “send order details to CRM”) with placeholders.

  4. System Fills Real Data – The system automatically replaces placeholders with the actual customer info.

  5. Action Done – CRM/Slack/Ticket system receives the correct data, and the response is shown to the user.

🖥 How to Add Variables in Your Widget

<script type="text/javascript" src="https://ctest.msg91.com/chat-widget.js"></script> 
<script type="text/javascript"> 
  var helloConfig = { 
    widgetToken: "ccb0ddf",   
     variables: {     
           user_id: "1234", 
           jwt_token: "dGZO...",
           mobile: "918987654310",    
           name: "codebro",     
           email: "[email protected]"  
           }
     };   
initChatWidget(helloConfig, 5000); 
</script>
  • variables: These are user details you want to pass to the bot.

  • AI cannot read these directly – it only uses them when an action is triggered.

🔒 Privacy & Security

  • Customer info is never shared with AI.

  • Details are only inserted when sending data to a tool (CRM, Slack, Ticketing, etc.).

  • Everything happens server-side – fully secure.

🧩 Placeholder Example
Let’s say you stored user’s first name like this:

name: { "first_name": "Nauman", "last_name": "Khan" }

When you want to use this in a tool, you call:

{{name.first_name}}

👉 Example:
 If the bot sends a Slack message → it will display:
 “Nauman has raised a support ticket.”

📌 Example Tool Call: Send to Slack

  1. User: “I need help with my order.”

  2. Bot: Prepares Slack tool call → {{name.first_name}} needs support for Order ID {{user_id}}.

  3. System replaces placeholders → Nauman needs support for Order ID 1234.

  4. Slack gets the final message.

📊 Tool Requirements

  • Each tool (Slack, CRM, WhatsApp, etc.) may need specific variables.

  • Example: user_id, jwt_token, email.

  • If missing, default values can be set in the widget.

🧪 Testing Checklist

  • Check if variables are added in widget config.

  • Ensure placeholders like {{name.first_name}} are resolving properly.

  • Validate required fields (like email, ID).

  • Test for error cases (e.g., missing variable).

🎯 Use Cases of This Feature
Here’s how businesses can benefit:

  1. E-commerce

    • Chatbot shares order details instantly with support agents.

    • Sends order confirmation or tracking updates directly using stored customer ID.

  2. Customer Support

    • Escalates issue to Slack or Ticketing tool with customer’s name & email auto-filled.

    • No need to ask the customer to repeat details.

  3. Sales Teams

    • Bot pushes lead info (name, email, phone) directly into CRM.

    • Makes follow-up faster with complete customer context.

  4. Banking & Finance

    • Securely validates account ID / transaction ID before processing requests.

    • Keeps sensitive details private from AI.

  5. Healthcare

    • Patient chats → Bot securely sends patient ID & appointment details to hospital system.

Why This Matters

  • Customers love it → no repeated questions, smoother experience.

  • Your team saves time → details automatically flow into the right system.

  • Your data stays safe → AI doesn’t see sensitive info.

📌 Next Step: Add your widget with variables → Build AI Chatbot → Start automating secure, personalized conversations.