tryingtocode
tryingtocode

Reputation: 57

Stream Chat System Message Customization

I've created a custom message type that I send via Python backend as a regular message type, howvever I can't figure out how to set the 'profile pic' or the name for the system message. I want to use our app's logo and name instead of the default picture and the name "system".

This is my message:

message = {
        "text": f"Today's reading: {passage_reference}",
        "isGroupPlanPassage": True,
        "passageReference": passage_reference,
        "passageData": {
            "planId": plan_data.get("groupPlanID"),
            "passageNumber": current_passage_number
        },
        "user": {"id": system_user_id},
        "type": "regular"
    }

I tried this, but it didn't work:

message = {
        "text": f"Today's reading: {passage_reference}",
        "isGroupPlanPassage": True,
        "passageReference": passage_reference,
        "passageData": {
            "planId": plan_data.get("groupPlanID"),
            "passageNumber": current_passage_number
        },
        "user": {
            "id": system_user_id,
            "name": app_name,
            "image": image_url},
        "type": "regular"
    }

Anyone tried this themselves? Is it even possible? Thanks!

Upvotes: 0

Views: 31

Answers (1)

Juan Elvir
Juan Elvir

Reputation: 1

You can set the message type to "system":

message = {
    "text": f"Today's reading: {passage_reference}",
    "isGroupPlanPassage": True,
    "passageReference": passage_reference,
    "passageData": {
        "planId": plan_data.get("groupPlanID"),
        "passageNumber": current_passage_number
    },
    "user": {
        "id": system_user_id,
        "name": app_name,
        "image": image_url},
    "type": "system"
}

You should be able to make it look different based on this and all the user info you pass through should be attached to the message.

https://getstream.io/chat/docs/python/silent_messages/

If you're using the react sdk on the front-end you should read this to customize it: https://getstream.io/chat/docs/sdk/react/guides/customization/system_message/

Upvotes: 0

Related Questions