Skip to main content

messages.initHistoryImport

Import chat history from a foreign chat app into a specific Telegram chat, click here for more info about imported chats ».

func (c *Client) MessagesInitHistoryImport(ctx context.Context, request *MessagesInitHistoryImportRequest) (*MessagesHistoryImport, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesInitHistoryImport(ctx, &tg.MessagesInitHistoryImportRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesHistoryImport
return nil
})

Parameters

NameTypeRequiredDescription
PeerInputPeerClassyesThe Telegram chat where the history should be imported.
FileInputFileClassyesFile with messages to import.
MediaCountintyesNumber of media files associated with the chat that will be uploaded using messages uploadImportedMedia.

Returns

*MessagesHistoryImport

Possible errors

CodeTypeDescription
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400IMPORT_FILE_INVALIDThe specified chat export file is invalid.
400IMPORT_FORMAT_DATE_INVALIDThe date specified in the import file is invalid.
400IMPORT_FORMAT_UNRECOGNIZEDThe specified chat export file was exported from an unsupported chat app.
400PEER_ID_INVALIDThe provided peer id is invalid.
400USER_NOT_MUTUAL_CONTACTThe provided user is not a mutual contact.

References