API経由で作成時にトピックやメッセージを割り当てる

I’d like to be able to create messages that are assigned to specific users. Is this something that is possible already and I am missing something, or that you would consider adding?

I am not seeing reference to the assign plugin in the API docs. Seems to me an e.g. assigned_to=usernname should be an option.

https://docs.discourse.org/#tag/Posts%2Fpaths%2F~1posts.json%2Fpost

The background to this is that I am using discourse as a ticket system, using @angus’s Tickets Plugin 🎟. The easiest way for me to allow members to create tickets is to create a gravity form in wordpress that creates the message in discourse. I know this can work and I have the rest of it lined up, just not the ability to assign tickets to specific users upon creation.

To assign a topic you issue an API request after creating the topic. For the request format, please read How to reverse engineer the Discourse API

「いいね!」 4

API を介してステージドユーザー(送信者に Discourse 内のアカウントは不要)としてトピックを作成する必要があります。そのため、/admin/email/handle_mail エンドポイントを使用する必要がありますが、このエンドポイントはトピック ID を返さず、バッチ処理のように動作するようです。

そのトピックを割り当てる最適な方法はどのようなものでしょうか?

私にとって最も望ましいのは、/admin/email/handle_mail エンドポイントが assign フィールドを受け入れるようにすることです。

なぜトピック作成用の handle_email エンドポイントをリバースしているのですか?

ステージングユーザーでは標準的なトピック作成 API を使用できないのでしょうか?

「いいね!」 1

API でステージング済みユーザーを作成するオプションが表示されません: Discourse API Docs

また、handle_email エンドポイントの使用が推奨されています: Creating a staged user with an API call - #2 by blake

それは行いません。これは受信メールの処理のみを目的としています。

実際には動作しません。403 エラーが発生します。

ただし、ステージング済みユーザーによる最新のトピックを取得するために、このエンドポイントを呼び出すことはできますか?

http://localhost:3000/topics/created-by/staged-username.json

その後、それを割り当てますか?

「いいね!」 2

エウレカ!

「他の正規表現を割り当てる」を使用し、/admin/email/handle_mail のテキスト内で言及することが可能です。

「いいね!」 1

こんにちは。

Discourse Assign プラグインを使用しており、実現できました。以下に Python コードを示します。

import requests

# これは、assign リクエストをリバースエンジニアリングし、以前に誰かが言及したようにコンソールでパラメーターと値を確認することで取得できます :)

base_url = 'YOUR_URL'
endpoint = '/assign/assign'

payload = {
    'username': 'USERNAME', # トピックを割り当てたいユーザー名
    'group_name': '',
    'target_id': TOPIC_NUMBER,
    'target_type': 'Topic'
}

headers = {
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Referer': 'URL_OF_THE_TOPIC',
    'Accept': '*/*',
    'Api-Key': 'YOUR_API_KEY',
    'Api-Username': 'YOUR_USERNAME'
}

response = requests.put(f"{base_url}{endpoint}", data=payload, headers=headers)

if response.status_code == 200:
    print("割り当てが成功しました!")
else:
    print(f"割り当てに失敗しました。ステータスコード {response.status_code}: {response.text}")

お役に立てば幸いです ^^

「いいね!」 1