1

This is the real data structure of my current json data, it contains [] in the data in the first place.

{"events":[{"type":"message","message":{"type":"text"}}]}

So, basically I just want text message type data from SQS, but now I don't know what should the filter be.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ben
  • 541
  • 1
  • 5
  • 15

1 Answers1

1

If you are using yaml in serverless, I´d try this:

filterPatterns:
    - body: {events: {type: ["message"], message: {type: ["text"]}}}

In case it helps, I had a similar scenario: in my case, I want a function to be triggered only when inside the body of the SQS message, the field "type" has values "create" or "delete"}

In my case, the next code worked:

filterPatterns:
    - body : {type: [create, delete]}
Markussen
  • 164
  • 1
  • 13
  • The second example worked very nicely for me after having tried many variants. Using AWS SDK 3, `SendMessageCommand`. `const body = { type : 'create' }` – lucsan Jun 06 '23 at 09:27