Importing Data

LAST EDIT Apr 26 2021

If you've just started using Stream, you might want to import data from your infrastructure or provider. Instead of using the APIs and creating your import scripts, you can make use of our import feature. 

The Process

Copied!

The steps for importing data into your app are as follows:

  1. Generate the import file for your data (full file reference below)
  2. Reach out to send us the import file or upload via the dashboard

  3. The file will be validated according to the rules described in this doc
  4. If validation passes, a member of our team will approve and run the import
  5. Once the import is completed (usually a few minutes), you will get a confirmation email
Before uploading the import file make sure that every feed group in your import file is configured in your app.
Importing data on a live app may cause high response times for requests during the import process.

Importing From Dashboard

Copied!

From your dashboard click on the ‘select app’ dropdown and select the app you wish to import chat data for. Then from the ‘chat’ dropdown click ‘Overview’. On the Overview screen click ‘Options’ and select ‘Import Chat Data’.

You are only allowed to import datta for apps in development mode.

You will be presented with a modal asking for a JSON file. Please ensure you follow our best practices below to format this file before uploading.

The max size of a file we are able to handle in an upload is 286MB please get in touch with support if you need to upload a larger file size.

The Upload

Copied!

Once you have uploaded your file scroll down on the chat overview page to see a ‘Data Import’ section. Here you can view some details about the file upload:

  • The person who uploaded the file

  • The date the file was uploaded

  • The filename that was uploaded

  • The current status of the upload

If your import fails validation on our end you can upload a new file by clicking on the ‘New Import’ button. To view more details of your import click on it within the list shown under ‘Data Imports’. This will show a modal where you can see the size of the import and a preview of the JSON that was uploaded.

What To Expect

Copied!

If your import correctly passes our validations we will begin the migration process. This can typically take 2-3 days. An email will notify you once the upload has completed. The dashboard will also update showing a status of ‘completed’ within the ‘Data Imports’ table. 

Should your import fail we will be in touch via email. You will also see the status in the ‘Data Impots’ table update to the particular reason as to why the import failed.

Import File

Copied!

The import file must be structured as a JSON array of objects. Each object is an item to add to your application (eg. a user, a message, etc.).

Here's an example of an import file:

Import Entries Format

Copied!

Name

Type

Description

type

string

the type of data for this entry. Allowed values are: user, channel, message, reaction, member

item

object

the data for this entry, see below for the format of each type

Item Types

Copied!

An import file can contain entries with any of these types.

Note that you can add custom fields to users, channels, members, messages, attachments and reactions. The limit is 5KB of custom field data per object.

User Type

Copied!

The user type fields are shown below:

Channel Type

Copied!

The channel type fields are shown below:

nametypedescriptiondefaultoptional
idstringthe unique id for the channel
typestringthe type of the channel. ie livestream, messaging etc.
created_bystringthe id of the user that created the message
frozenbooleanyou can't add messages to a frozen channelfalse
*string/list/objectadd as many custom fields as needed

Member Type

Copied!

Channel members store the mapping between users and channels. The fields are shown below:

Message Type

Copied!

message creation time in RFC3339 format

last time the message was updated

message deletion time in RFC3339 format

reply messages are only shown inside the message thread unless show_in_channel is set to true, in that case the message is shown in the channel as well

Add as many custom fields as needed

nametypedescriptiondefaultoptional
idstringthe id of the messageA random UUIDv4
channel_typestringthe type of channel for this message
channel_idstringthe id of the channel for this message
typestringthe type of the message, regular, deleted or systemregular
userstringthe id of the user that posted the message
attachmentslist of attachmentslist of message attachments, see the attachment section below[]
parent_idstringthe id of the parent message (if the message is a reply)null
created_atstring
updated_atstringcreated_at
deleted_atstringnull
show_in_channelboolfalse
*string/list/object

Message Attachments

Copied!

The only required field of an attachment is "type". All other fields are optional, and you can add as many custom fields as you'd like. The attachments are a great way to extend Stream's functionality. If you want to have a custom product attachment, location attachment, checkout, etc., attachments are the way to go. The fields below are automatically picked up and shown by our component libraries.

Reaction Type

Copied!

The reaction type has the following fields:

nametypedescriptiondefaultoptional
message_idstringThe id of the message
typestringThe type of reaction (up to you to define the types, it's a string)
user_idstringThe ID of the user
created_atstringThe creation time in RFC3339
*string/list/objectAdd as many custom fields as needed