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
  • Deployment
  • Bot as an API

How to create/update a Haptik User using API?

Written by Medha Anand

Updated on August 20th, 2021

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

Create or Update Haptik User API

Eventually, when you will be sending messages via Haptik, you will provide Haptik with a unique id for every user (auth_id). This is supposed to be the unique identifier for the user in your system.

Before sending any message to Haptik, you need to register the user, during this phase you could also provide additional information like:

- name
- mobile number
- email
- language preference
- phone model
- os version
- package name

The User API allows you to register the user via a POST request or update the user info via a PUT request to the Haptik Platform.

URL

Staging endpoint: https://staging-messenger.haptikapi.com/v1.0/user/

Production URL will be shared by your Haptik SPOC

Headers

Authorization: Bearer <TOKEN>
client-id: <CLIENT_ID>
Content-Type: application/json
  • Authorization - The Authorization header of each HTTP request should be “Bearer” followed by your token which will be provided by Haptik
  • client-id - The client id for your account which will be provided by Haptik
  • Content-Type - application/JSON

Request

{
 "auth_id": "<AUTH_ID>",
 "mobile_no": "<MOBILE_NO>",
 "email": "<EMAIL>",
 "name": "<NAME>",
 "language_code": "<LANGUAGE_CODE>",
 "custom_data": "<FLAT JSON OBJECT>"
}
  • auth_id - This is an alphanumeric User identifier from your System

  • mobile_no (optional) - Mobile no of the user

  • email (optional) - Email of the user

  • name (optional) - Name of the user

  • language_code (optional) - This is a language identifier for user's preferred language based on ISO 639-1 (standardized nomenclature used to classify language) Eg: en for English, hi for Hindi(optional)

  • phone model (optional) - Phone model/type that the user is using

  • os version (optional) - OS version of where the user is coming from (Android, iOS, Windows etc.)

  • package name (optional)- An identifier to differentiate between different Apps on the device (WhatsApp or custom client app)

  • custom_data (optional) - Any additional information about the user (which could not be captured by any of the above fields) should be added as a part of this flat JSON structure.
    Thus, additional information like country, city, date of birth, etc. which needs to be stored along with the user, should go here as:

    {
     "country": "India",
     "city": "Mumbai",
     "date_of_birth": "25-03-1985"
    }

    Rules for valid custom_data value:

    • The value assigned to custom_data should always be a valid JSON.
    • This value should always be a flat JSON. In other words, no property can have a JSON object assigned to it.
      For instance, the below JSON, though a valid JSON in itself, will still be considered as an invalid custom_data value since the property, address, is assigned a JSON object:
      {
       "date_of_birth": "12-8-1993",
       "address": {
       "country": "India",
       "state": "Goa"
       }
      }
      The suggested way is to flatten the above JSON as:
      {
       "date_of_birth": "12-8-1993",
       "country": "India",
       "state": "Goa"
      }

Response

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

{
 "auth_id": "<AUTH_ID>",
 "mobile_no": "<MOBILE_NO>",
 "email": "<EMAIL>",
 "name": "<NAME>"
}

Error Response

If the Authorization header is missing or invalid, then the API will return a 401 status code.

{
 "error_message": "invalid authorization details"
}

Sample CURL command

Create User

curl -X POST \
 https://staging-messenger.haptikapi.com/v1.0/user/ \
 -H 'Authorization: Bearer <TOKEN>' \
 -H 'client-id: <CLIENT_ID>' \
 -H 'Content-Type: application/json' \
 -d '{"auth_id": "<AUTH_ID>", "name": "guest user", "language_code":"<LANGUAGE_CODE>",
 "custom_data": {
 "<key_1>": "<value_1>",
 "<key_2>": "<value_2>"
 }}'

Update User

curl -X PUT \
 https://staging-messenger.haptikapi.com/v1.0/user/ \
 -H 'Authorization: Bearer <TOKEN>' \
 -H 'client-id: <CLIENT_ID>' \
 -H 'Content-Type: application/json' \
 -d '{"auth_id": "<AUTH_ID>", "name": "guest user", "language_code":"<LANGUAGE_CODE>",
 "custom_data": {
 "<key_1>": "<value_1>",
 "<key_2>": "<value_2>"
 }}'

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • What are the security protocols to follow for using APIs?
  • Which information is sent as Webhook Payload?
  • How to ensure API security?
  • What is Bot as an API?

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