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
  • Developer Guides

Different APIs that Can be Used on Conversation Studio

Written by Medha Anand

Updated on April 19th, 2023

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

Move a chat to pendingGet Chat Transcripts v2.0FAQ Step Creation APIs for KMSPolling API to fetch submitted task StatusBest Practices

Move a chat to pending

This API allows you to move chats for a Bot to an Agent via a POST request to the Haptik Platform.

Example URL: https://<base-url>/integration/external/v2.0/send_chat_to_agent/

Note: The base-url will be provided by Haptik at the time of integration.

Headers

Authorization: Bearer <TOKEN>
client-id: <CLIENT_ID>
Content-Type: application/json
Delete

You can read more about fetching these credentials here.

Request

{
 "team_name": "<Name of the team>",
 "user_name": "<haptik user name>",
 "business_id": "<business_id>",
 "countdown": "<time_in_seconds>",
 "receiver": "athena"
}
  • user_name (string): Identifier for the User provided by Haptik when invoking the Integration API

  • business_id (number): This is a numeric identifier for the channel where the User is messaging

  • team_name (string): Name of the team to which the chat is to be assigned. Can be fetched from the Teams page of Agent Chat Tool.

  • countdown (number): If value is set to 5, then after 5 seconds chat will be moved to the queue. Otherwise, the chat will be moved to the queue after 10 seconds (default), value can be from range 5 to 10 seconds.

  • receiver (athena): Athena is Haptik's internal Smart agent chat. This helps identify to if the chat transfer should happen to SAC.

Response

A successful request to the API will return a 200 status code with a JSON response object.

{
 "success": true
}
  • success: Indicates if the API was a success or failure

Error Response

If there is an error in the Headers or the Request body, then the Error message will be returned in a JSON as shown below:

{
 "error_message": "user is not registered"
}

Here is a list of some possible error messages

Error Message Details
client_id missing in headers client-id is not passed in the Headers of the request
invalid client_id in headers Incorrect client-id is passed in the headers
invalid authorization in headers The Authorization header is not correct
token missing in headers The Authorization token is not provided
invalid token provided The Authorization token provided is incorrect
user_name missing in the request The user_name is not provided in the request body
business_id missing in the request The business_id is not provided in the request body
team_name missing in the request The team_name is not provided in the request body
invalid user_name The user_name provided is not valid for the Account
invalid business_id provided The business_id provided is not valid for the Account
business "<business_id>" is inactive The business is inactive for the Account
invalid team_name provided The team_name is not valid for the Account
team "<team_name>" is inactive The associated Team is inactive
user has not sent a message The user has not had any chat on that Business

Sample CURL command

curl -X POST \
 https://<base-url>/integration/external/v2.0/send_chat_to_agent/ \
 -H 'Authorization: Bearer <TOKEN>' \
 -H 'client-id: <CLIENT_ID>' \
 -H 'Content-Type: application/json' \
 -d '{
 "team_name": "<Name of the team>",
 "user_name": "<haptik user name>",
 "business_id": <business_id>,
 "receiver": "athena"
}

Get Chat Transcripts v2.0

This API allows you to get the chat history of the user for a conversation via a GET request to the Haptik Platform.

Example URL: https://<base-url>/integration/external/v2.0/get_chat_history/

Note: The base-url will be provided by Haptik at the time of integration.

Headers

Authorization: Bearer <TOKEN>
Client-ID: <CLIENT_ID>
Content-Type: application/json

Delete

You can read more about fetching these credentials here.

To get the <TOKEN> value, you need to navigate to Admin tools > Partner list > Search for your account name > Edit. You can copy the token value from the Client Auth Token field.

Request parameters

parameter type required group description
business_id str(int) grouped 1 Business ID for
user_name str grouped 1 Haptik user name.
conversation_no int true 1/2 Conversation number of user's chat.
pxut str grouped 2 TRACT Packed eXtensible User Token.
limit str(int) optional n/a Limit on number of messages that the API should return.
response_type str optional n/a Either json (default) or text.

This API allows for fetching the transcripts using either:

  • Group 1: for native Haptik consumers

    • business_id
    • user_name
    • conversation_no
    • {
       "business_id": "1234",
       "user_name": "ab112468917fgghdebc",
       "conversation_no": 2
      }
  • Group 2: for TRACT consumers
    • pxut
    • conversation_no
    • {
       "pxut": "tw389ysgd._aksdjknsk-545641964-B",
       "conversation_no": 2
      }

Note: All arguments within a group are required. If both groups' arguments are provided, first will be preferred.

Response

A successful request to the API will return a 200 status code with a default JSON response object containing chat data.

JSON response
{
 "chat_json": [
 {
 "text": "Search places to visit{task}",
 "sender": "user",
 "message_id": 1742,
 "timestamp": "06/22/20 07:24:25 AM UTC"
 },
 {
 "text": "TEXT",
 "sender": "bot",
 "message_id": 1743,
 "timestamp": "06/22/20 07:24:26 AM UTC"
 }
 ]
}
Text response
{
 "chat_text": "user: Search places to visit{task}\nbot: TEXT\n"
}
Sender values
value description
bot message was sent by the bot
user message was sent by the user
<agent_name> message is sent by an agent, <agent_name> is the name of the agent who sent the message

Error Response

If there is any error in the Headers or the Request body, then the Error message will be returned in a JSON as shown below:

{
 "error_message": "<error_message>"
}

Error messages

Error Message Details
Invalid business_id business_id was not a valid string representation of an integer.
Invalid token The Authorization token provided is incorrect
Either the user has not sent a message yet, or the provided user_name-business_id pair is invalid. Check that the user_name matches the business_id that you are requesting data for, or wait for the user to send a response before sending this request.
Unable to decode pxut-client_id pair The TRACT PXUT is mismatched with the client_id provided in the request headers, or one of them is incorrect. Please recheck both.
Argument group validation: no valid group. Verify that parameters have been provided to fulfill at least one request group specified above. See response data for more details.
Argument group validation: invalid group found. Verify that the parameters provided are of a valid type. See response data for more details.
An unknown error occurred Please contact the Haptik team for support.

FAQ Step Creation APIs for KMS

We have many clients who need FAQ bots. Every time when we want to change the content of these FAQs (Q&As), a new CSV with Step name, Question and Answer in a defined format needs to be uploaded. (Format given below)

We have developed an API that can be integrated with the client KMS(Knowledge Management Systems) via any intermediate layer and every time when data gets changed in KMS, it should call this API to keep data in sync with the Haptik systems.

This API allows you to create/update/delete faq steps via a POST request to Haptik Platform.

Note: The base-url will be provided by Haptik at the time of integration.

FAQ Step creation process API consists of two parts:

  1. Submit the CSV: To handle the large CSV files, this API takes the request data and after validation submit it to the celery worker and returns the task id, which executes the task asynchronously.
  2. Polling API to fetch the status of submitted task id

Example URL: https://<base-url>/mogambo_api/nodes/faq/create/

1. node_name: Name of the step, step name should be unique
2. Question(User Message): Independent Responses under User Message to detect this FAQ step. Multiple user message for single node can be passed as pipe(|) separated values(refer the sample row in image above)
3. answer(bot response): A step can have single or multiple bot response, to pass multiple bot responses use `<m>` tag as delimiter

Headers

Authorization: Bearer <TOKEN>
client-id: <CLIENT_ID>
Content-Type: multipart/form-data
Delete

You can read more about fetching these credentials here.

Request Body

"domain_name": "<Name of the Domain/Bot>",
"csv_file": filename.csv,

Response

A successful request to the API will return a 200 status code with a JSON response object.

{
 "success": true,
 "body": {
 "task_id": "fe139ce5-f4c3-4383-bacb-64a546cb0b6c"
 },
 "error": "",
 "meta": {}
}
  • success flag Indicates if the API was a success or failure
  • task_id: Job id for the submitted task

Error Response

If there is an error in the Headers or the Request body, then the Error message will be returned in a JSON as shown below:

{
 "error_message": "invalid doman"
}
Error Code Error Message
401 Unauthorized Access or invalid token
400 Invalid or bad request body
403 Access Forbidden

Sample Curl Command to submit CSV file and get job id

curl -X POST \
 https://<base-url>/mogambo_api/nodes/faq/create/ \
 -H 'authorization: Bearer <token>' \
 -H 'client-id: <client-id>' \
 -H 'content-type: multipart/form-data;
 -F 'domain_name=<domain_name>' \
 -F csv_file=@filename.csv

Note: This API follows the upsert [UPDATE and INSERT] behavior i.e. every time when new CSV gets uploaded it makes the existing FAQ steps for that domain inactive, creates new steps for the rows mentioned in the CSV, and updates steps with the same names with the new User Message and Bot Response from the CSV.

Polling API to fetch submitted task Status

This API allows you to see the status of the submitted task id via a GET request to Haptik Platform.

Example URL: https://<base-url>/mogambo_api/nodes/faq/create/status/<task_id>/

task_id: Id of task which gets created when we submit csv to step creation api

Headers

Authorization: Bearer <TOKEN>
client-id: <CLIENT_ID>
Delete

You can read more about fetching these credentials here.

Response

A successful request to the API will return a 200 status code with a JSON response object.

{
 "success": true,
 "body": {
 "status": "all steps have been created successfully"
 },
 "error": "",
 "meta": {}
}
  • success flag Indicates if the API was a success or failure

Sample Curl Command to get the task status

curl -X GET \
 https://<base-url>/mogambo_api/nodes/faq/create/status/<task_id>/ \
 -H 'authorization: Bearer <TOKEN>' \
 -H 'client-id: <CLIENT ID>' \

Possible Statuses:

Error/Exception: shows the exception/error that occurred for the last step and stops the execution

In Progress: Step Creation is in progress

Success: Step has been created successfully

Best Practices

1. Assign Chat to Agent - In some scenarios, where integration response fails or some unknown exception occurs then instead of sending bot break message we can also directly assign the chat to an agent for better user experience.

2.Handle textual content - Every time we want to change the bot's response, a code change is required. To avoid that pain, we can use key-value stores. Any person with zero to little tech knowledge can change bot response from the key-value store (with GUI) by updating the message copy corresponding to that unique message key or ID. This message key can be shared with the developer and fetch the response using that key.

3. HSL's - Haptik defines a superset of UI elements that are available across multiple platforms. These UI elements are then converted to their platform equivalent (js-SDK, android, ios, facebook-messenger, etc..) if they are not available on that specific platform. Eg. Forms are converted to quick replies on the Facebook platform and collected over free form. For more detail read here.

4. Calling the API - There is no limit to the number of calls that you can make to the APIs. However, if Haptik detects a DDOS attack (100-200 calls/sec) then Haptik will block your requests, The recommended rate at which you can call the API is around a max of 100 Calls/minute.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How to Send Entity Values to API to Fetch Data
  • Using Environment Variables
  • What is Static Step Integration
  • Using "final_response" in Main Method

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