Martin 0x522E
11/13/2024, 9:49 AMtimestamp
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
json
{ "message": {
"role": "assistant",
"status": "stopped",
"timestamp": 1731428357962,
"type": "speech-update"
}
}`
when trying to read it with
go
var body api.ServerMessage
err := json.Unmarshal([]byte(jsonStr), &body)
if err != nil {
t.Fatal(err)
}
it fails because of this field
go
// This is the ISO-8601 formatted timestamp of when the message was sent.
Timestamp *string `json:"timestamp,omitempty" url:"timestamp,omitempty"`
Martin 0x522E
11/13/2024, 9:50 AMVapi
11/13/2024, 9:51 AMgo
// 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.Vapi
11/13/2024, 9:51 AMVapi
11/13/2024, 9:54 AMMartin 0x522E
11/13/2024, 9:54 AMMartin 0x522E
11/14/2024, 9:07 AMShubham Bajaj
11/15/2024, 3:30 PMShubham Bajaj
11/16/2024, 7:06 PM