Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Go to Haptik Website
  • Contact Us
  • Home

How to setup Team-based routing for Smart Agent Chat?

Written by Soham Amburle

Updated on October 7th, 2022

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
    Build Deploy Analyse Manage Account Bot Deactivation
  • Bot Building
    Essentials Smart Skills Steps User Messages Bot Responses Entities Connections Customisations User feedback collection Testing Whatsapp Bots NLU Bot Maintenance
  • Smart Agent Chat
    Set up Admin Settings MyChats Section (Agent Inbox) Live Traffic Section Teams Section Archives Section Analytics Plans on Smart Agent Chat
  • Conversation Design
    Design Basics Design Guides Designing for Platforms Designing WhatsApp Bots
  • Developer Guides
    Code Step Integration Static Step Integration Shopify Integration SETU Integration Exotel Integration CIBIL integration Freshdesk KMS Integration PayU Integration Zendesk Guide Integration Twilio Integration Razorpay Integration LeadSquared Integration USU(Unymira) Integration Helo(VivaConnect) Integration Salesforce KMS Integration Stripe Integration PayPal Integration CleverTap Integration Fynd Integration HubSpot Integration Magento Integration WooCommerce Integration Microsoft Dynamics 365 Integration
  • Deployment
    Web SDK WhatsApp Facebook Instagram Sunshine Conversation LINE Google Business Messages Telegram MS Teams Bot as an API iOS SDK Android SDK
  • External Agent Tool Setup
    Zendesk Chat Salesforce Service Cloud Freshchat Zoho NICE CXOne Gorgias
  • Analytics & Reporting
    Intelligent Analytics
  • Notifications
    SMS Notifications Success Measurement
  • Commerce Plus
    Catalog Integration Bot Building Guide Channel Deployments Unified ML Pipeline Documentation
  • Troubleshooting Guides
    Error Messages FAQs
  • Release Notes
+ More

Table of Contents

Table of Contents Understanding Team-based Routing Implementation Code Step Integration for Team-based Routing How does the above code work for Team-based Routing?

Table of Contents

Understanding Team-based RoutingImplementationCode Step Integration for Team-based RoutingHow does the above code work for Team-based Routing?

Understanding Team-based Routing

Consider, the user has come up with an issue on some topic, and he has requested to chat with an agent. With Team-based routing, his issue will be handed over to an agent, from the team that deals with the topic of the users' interest. So, this would help in reducing the delay in response from the agent.

Example: In a Software business, if the user has an issue with installation, then his request to chat with an agent would be directed to the agent who belongs to the installation team, and not the agent from any other team like integration or feedback.

Implementation

In order to implement this Team-based routing algorithm, you would have to follow certain steps.

  • In your Bot, you would have to add a Code step. 
  • This code step would serve the user's Chat with an Agent request.
  • You can add the below-mentioned code in that code step. 
  • The code would get implemented every time the user requests for chatting with an agent.

Code Step Integration for Team-based Routing

import json
import requests
def main(event, context):
    """
   event['body'] is a string dict with the following keys:
   node, event, user, entities.
   Currently, we pass user_id, user_name, full_name, device_platform and language_code in the user dictionary.
   Args:
       event (dict): Data corresponding to this event
       context
   Returns
       (dict): response with statusCode and the response for the User
   """
    body = json.loads(event['body'])
    entities = body.get('entities')
    user_data = body.get('user')
    user_name = body.get('user')["user_name"]
    user_details = body.get('user_details')
    environment_variables = body.get('env_variables')
    # TODO change default team name
    team_name = user_details.get('team_name', 'Default')
    team_name = "haptik_" + team_name
    transfer_status = transferChatToAgent(user_name, team_name, environment_variables)
    conversation_details = body.get('conversation_details')
    final_response = {
        'status': transfer_status,
        'entities': entities,
        'user_full_name': user_data.get("full_name"),
        'user_device_platform': user_data.get("device_platform"),
        'conversation_details': conversation_details,
        'team_name': team_name
    }
    response = {'statusCode': 200, 'body': json.dumps(final_response), 'headers': {'Content-Type': 'application/json'}}
    return response
def transferChatToAgent(user_name, team_name, environment_variables):
   location = entities.get(‘user_location’)[0].get(‘entity_value’)
   url = environment_variables.get("HAPTIK_API_BASE_URL") + "/integration/external/v2.0/send_chat_to_agent/"
   payload = {"team_name": team_name, "user_name": user_name, "business_id": xxxx, "receiver":"athena"}
   header = {
       'Content-Type': 'application/json',
       'Authorization': f"Bearer {environment_variables.get('HAPTIK_API_TOKEN')}",
       'client-id': 'xxxx'
   }
   try:
       response = requests.request("POST", url, headers=header, json=payload)
       response.raise_for_status()
       print(f"[transferChatToAgent] API schematics headers: {header} payload:{payload} response {response.json()}")
       return True
   except Exception as e:
       print(f'[transferChatToAgent] API failed due to {e} request {header} response {response.json()}')
       return False


team_name = {
mumbai = team_mumbai # team_mumbai is the Team name on Smart Agent Chat
new_York = team_ny
}
Delete

In the above code, you would need to add the following variable data:

  • HAPTIK_API_BASE_URL
  • HAPTIK_API_TOKEN
  • client-id

Visit this link, to know how to obtain these values. 

How does the above code work for Team-based Routing?

  • When the user wants to talk to the agent, in order to get certain information, it is imperative that he is directed to the right agent, from the right team. So that, it saves the user's time and also gives him a good product experience.
  • The above code uses users' locations to find out where the user is operating from. The below-mentioned function is the one used for acquiring users' location-related data.
    location = entities.get(‘user_location’)[0].get(‘entity_value’)

This code deals with location-based data. But you can configure it the way you want by making changes to the code depending on your requirement. So teams could be seniority-based, topic-based, department-based, etc.

Example:

If the bot serves the book publishing business, then the teams could be:

  • Writing team
  • Copywriting team
  • Proofreading team
  • Publishing team

Depending on the user's issue, he would be assigned an agent from any of the teams above. 

  • It would collect the user's location data and would use it for directing the user to the right team based on his location.
  • Consider, the user is working from Mumbai and has put up a request to chat with an agent. Now, with this code's configuration, initially, the user's location would be collected and stored.
  • Now that the bot has the user's location, the bot knows where the user is based and which team the user should be directed to.
  • If there are teams based in Mumbai, New York, London, and so on. Ideally, the team from Mumbai would be able to provide the right resolution to the user, as per the code.
  • This approach would ensure reduced delay in response from the agent. Since, both the user and agent would be from the same geographic location, it would be less likely to have a delay in response from the agent, if we compare it with the agents from the other locations.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Using "final_response" in Main Method
  • How to setup Time-based routing for Smart Agent Chat?
  • Using "user_details" Variable
  • How to Configure Ticketing on Salesforce?

Platform

  • Conversation Studio
  • Smart Skills
  • Advanced NLU
  • Intelligent Analytics
  • Omnichannel
  • Smart Agent Chat
  • Enterprise Security
  • Integrations

Solutions

  • Conversational Commerce
  • Lead Generation
  • Customer Care
  • WhatsApp
  • Conversational IVR
  • Google Business Messages

Industries

  • Retail/ E-Commerce
  • Financial Services
  • Travel & Hospitality
  • Telecom

Knowledge

  • ROI Calculator
  • Reports & Research
  • Case Studies
  • Webinars
  • ISAT
  • Tech Blog
  • Business Blog
  • Resources
  • Haptik v/s Yellow
  • Haptik v/s Liveperson
  • Haptik v/s IBM Watson
  • Haptik v/s Verloop
  • Conversations on AI

Company

  • Why Haptik
  • About Us
  • Careers
  • News & Media
  • Awards & Recognition
  • Contact Us
  • Partnerships
  • Investor Relations

Subscribe

Sign up to recieve the latest updates

Find us on

  • Twitter-footer
  • Linkedin-footer
  • YT-footer
  • Insta-footer
  • G2-footer
  • Facebook-footer

Knowledge Base Software powered by Helpjuice

Copyright © jio Haptik Technology Limited 2021 | Data Security & Privacy Policy | GDPR

North America | Asia Pacific | Africa | enterprise@haptik.ai

Definition by Author

0
0