Reply to message thread

Send a reply to a message thread in Toloka.

Steps to follow

1. Import Toloka-Kit

Connect the Toloka-Kit library to your script.

import toloka.client as toloka

2. Instantiate TolokaClient

Replace the sample API key with your own one.

toloka_client = toloka.
TolokaClient
('PlaceYourRealApiKey_Here', 'PRODUCTION');

3. Send reply to thread

Find out the ID of the message thread you want to reply to. Then compose a reply using the MessageThreadReply class object for that.

message_reply = toloka.message_thread.
MessageThreadReply
(text={'EN': 'Thank you!'})
response_to_thread = toloka_client.
reply_message_thread
(
message_thread_id='63c15cfd757a4a1adad1d633',
reply=message_reply
)

4. Display sent reply info

The reply_message_thread() request will return the MessageThread class object. You can use its attributes to print the information you need.

print(response_to_thread.id, response_to_thread.created)

You should get an output with the message ID and creation time which looks like this.

63c15cfd757a4a1adad1d633 2023-01-13 13:36:13.894000+00:00

Complete code: Reply to message thread

import toloka.client as toloka
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
message_reply = toloka.message_thread.MessageThreadReply(text={'EN': 'Thank you!'})
response_to_thread = toloka_client.reply_message_thread(
message_thread_id='63c15cfd757a4a1adad1d633',
reply=message_reply
)
print(response_to_thread.id, response_to_thread.created)
List of classes and methods used in this recipe

See also

Last updated: February 7, 2023

Toloka-Kit
OverviewGetting API keyQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming