What is Multipart form data format in APIs?
Multipart form data format in REST APIs combines one or more sets of data into a single body, separated by boundaries. You typically use these requests for file uploads and for transferring data of several types in a single request (for example, a file along with a JSON object).
With Multipart form data support in our API library, our customers can pass file attachments and other information collected during the bot conversation to a 3rd party application.
For example, when an end-user is interacting with the bot, the Multipart form-data format in REST APIs will enable the bot to collect additional context with file attachments and pass it on to Freshdesk to create a ticket.
Setting up multipart API in Bot builder for Freshchat
- Go to Bots from the left pane.
- Create a new bot or select the bot you want to edit.
- Navigate to Flows > Configure > API library.
- The New API button will allow you to configure a new API call.
- When you choose a method like POST or PUT, - you will get an option to select between JSON or Multipart form data Payload types.
- On selecting the Multipart form data Payload type, a set of structured payload content fields will be available for configuration.
- In this payload, you can enter the key name along with its content type. The content type associated with the key can be either text or file type.
- For the key with content type as text, the equivalent value can be hardcoded or can be configured using a content picker.
- For the key with content type as File, the value can be a dialog content picker where the file/attachment input was configured. In the above image example: In the conversational flow, 3.1 dialog is configured to collect attachment or file from the customer, the content picker associated with this dialog can be used in the corresponding multipart form data API to pass this attachment to a third party system.
- Once you have configured the multipart form data API, you can trigger the API in bot flow.
- On success, a record will be created on the concerned 3rd party app with the relevant text or attachment.
- If the API fails, the relevant API status and logs will be available to debug and correct the API configuration.