SMS webhook assistance

Don’t forget to change the webhook back :slight_smile:

YOU DID IT!!!

Seriously your help here has been amazing. I am so grateful.

How did you determine the structure of Twillio’s data like that?

1 Like

Glad to be of service :slight_smile:

I modified that example app I sent you.
I created a Data Table with two columns, “key” & “value”.
I then looped around the kwargs that were received and stored them in the table like this :

@anvil.server.http_endpoint("/test")
def test(**kw):
  for k,v in kw.items():
    app_tables.log.add_row(key=k,value=v)

Brilliant, and so that let you know about the exact fields that Twillio sends to the Anvil app. Really cool stuff. I’m so out of my element with the web.

I really can’t thank you enough.

Al

1 Like

Nice to see you’ve got it working!

If you want named keyword arguments, you can supply them explicitly in the signature, and catch any other query parameters with **kw. Using David’s example:

@anvil.server.http_endpoint("/test")
def test(From=None, Body=None, **kw):
  if From is not None:
    app_tables.log.add_row(key='From', value=From)
  if Body is not None:
    app_tables.log.add_row(key='Body', value=Body)
  for k,v in kw.items():
    app_tables.log.add_row(key=k, value=v)
2 Likes

This is great. Thanks Shaun!