Haptik Docs

Haptik Docs

  • Tools
  • Integrations

›Setup

Getting Started

  • What is a Webhook

Pre-requisites

  • API Security
  • Protocols
  • Payload Information

Setup

  • How to create/update a Haptik User
  • How to send message to Haptik
  • How to send file to Haptik
  • How to send feedback to Haptik

Bot Deployment

  • Using Platform Deployments

Miscellaneous

  • Synchronous Webhooks
  • How to re-enable Webhook

How to send file to Haptik

File Upload

The File upload API allows you to upload user files via a POST request to the Haptik Platform. The URL for file uploads is generated on the Haptik Platform Dashboard.

URL

https://<BASE_URL>/v1.0/log_file_from_user/

Headers

Authorization: Bearer <TOKEN>
client-id: <CLIENT_ID>
Content-Type: multipart/form-data
  • 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 - multipart/form-data

Request

{
  "auth_id": "<AUTH_ID>",
  "business_id": "<BUSINESS_ID>",
  "message_type": "<MESSAGE_TYPE>",
  "message_body": "<MESSAGE_BODY>",
  "file": "<FILE>"
}
  • auth_id - This is an alphanumeric User identifier from your system
  • business_id - This is a numeric identifier for channel/queue on which the message is to be registered.
  • message_type - The message type should be 1 for image and 52 for document
  • file - contents of the file (binary). Max file sze allowed is 10MB
  • message_body (optional) - The message body containing the message to be sent to the bot or agent.

Supported Extensions

  • Document: docx, doc, pdf, xls, xlsx, csv
  • Image: jpg, jpeg, png, gif

Response

A successful request will return a 200 status code with a JSON response object with a unique message id and other metadata about the messages.

{
  "message_id": 1411200492,
  "message_body": "<MESSAGE_BODY>",
  "created_at": "2018-10-04T12:41:27.980Z",
  "message_type": 1,
  "file_url": "https://assets.haptikapi.com/content/42e123411bk1109823bf.jpg"
}
  • message_id - message id generated by haptik system
  • message_body - message body that was logged in the haptik system
  • created_at - ISO timestamp denoting when the message was created in the haptik system
  • message_type - The message type should be 1 for image and 52 for document
  • file_url - The url for the uploaded file

Error Response

If the user with auth_id is not registered, then the API will return a 403 status code.

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

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

curl -X POST\
    https://<BASE_URL>/v1.0/log_file_from_user/ \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'client-id: <CLIENT_ID>' \
  -H 'Content-Type: multipart/form-data' \
  -F "auth_id=<AUTH_ID>" \
  -F "business_id=<BUSINESS_ID>" \
  -F "message_type=1" \
  -F "file=@/home/user1/Desktop/test.jpg" \
  -F "message_body="
Last updated on 4/16/2021
← How to send message to HaptikHow to send feedback to Haptik →
  • File Upload
    • URL
    • Headers
    • Request
    • Response
    • Error Response
  • Sample CURL command
Haptik Inc.
Tools
Conversation StudioSmart Agent ChatIntelligent Analytics
Integrations
iOS SDKAndroid SDKWeb SDKWhatsAppFacebookBot API
Others
HSLSLAExternal Agent Chat Tool
Copyright © 2021 Haptik Inc.