Golang types for server messages wrong
# support
m
The
timestamp
is sent as a unix timestampt (number), but the types specify it's a string which then fails unmarshalling of every webhook message! e.g. this is the message
Copy code
json
{ "message": {
        "role": "assistant",
        "status": "stopped",
        "timestamp": 1731428357962,
        "type": "speech-update"
    }
}`
when trying to read it with
Copy code
go
    var body api.ServerMessage
    err := json.Unmarshal([]byte(jsonStr), &body)
    if err != nil {
        t.Fatal(err)
    }
it fails because of this field
Copy code
go
    // This is the ISO-8601 formatted timestamp of when the message was sent.
    Timestamp *string `json:"timestamp,omitempty" url:"timestamp,omitempty"`
this makes it impossible to process any webhook message
v
@Martin 0x522E I understand the issue you're facing with the timestamp format. It seems there's a discrepancy between the expected type in the Go struct and the actual type being sent in the webhook message. The webhook is sending a Unix timestamp as a number, while the Go struct expects a string. To resolve this, you can modify the Go struct to expect an integer for the timestamp, like so:
Copy code
go
// This is the Unix timestamp of when the message was sent.
Timestamp *int64 `json:"timestamp,omitempty" url:"timestamp,omitempty"`
Then, you can convert the Unix timestamp to an ISO-8601 formatted string if needed elsewhere in your code. If you do not have control over the struct and need further assistance with this issue, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
m
@User ?
s
Hey @Martin 0x522E your ticket was marked as looking, which made it slip through my list.
hey @Martin 0x522E I have informed the team, and they will be taking from there.
3 Views