You can use Multipart APIs to combine and send multiple data sets, such as attachments, from your bot conversations to your preferred third-party systems.
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, you can pass file attachments and other information collected during the bot conversation to third-party applications that support REST APIs.
- For example, when your customers interact with your bot, you can use the Multipart form data format in REST APIs to collect additional context with file attachments and pass it to Freshdesk to create a ticket.
Setting up multipart API
- Navigate to Bots and create a new bot or select an existing bot
- Navigate to Flows > Configure > API library > New API button
- When you choose a method like POST or PUT, you can define the payload type from the following options: JSON, Multipart form data, and URL Encoded form.
- Choose Multipart form data from the Payload type dropdown. You can now see that a set of structured payload content fields will be available for configuration.
- You can enter the key name and its content type in this payload. The content type associated with the key can be either text or file type.
Using bot flows to collect data for multipart API
Content type: Text
- For the key with content type as text, the value can be hardcoded or can be configured using a content picker from a Dialog that collects Text field input. In this example, Dialog 1.2 will collect Text input from the customer:
- The Multipart form data API can be configured to get the value from Dialog 1.2, which can then be passed on via the API.
- If required, you can replace the dynamic value with a static text value. This is useful if you need to share only one value for all customers, such as the language (if you are only offering your services in one language, for example).
Content type: Attachment
- For the key with content type as File, configure the value using a content picker from a Dialog that collects File and Image input. In this example, Dialog 3.1 will collect a File or Image from the customer.
- The Multipart form data API can be configured to get the value from Dialog 3.1, which can then be passed on via the API.
Triggering the Multipart API in the bot flow
- Once you have configured the multipart form data API, you can trigger the API in bot flow.
- If the API call is successful, the relevant text or attachment will be passed on to your third-party application.
- If the API call fails, the relevant API status and logs will be available under Conversations > API calls to debug and correct the configuration.