Skip to content

Instantly share code, notes, and snippets.

@epmallmann
Created May 23, 2020 18:48
Show Gist options
  • Save epmallmann/1065d49e06442ac0657c3cb5f12627ce to your computer and use it in GitHub Desktop.
Save epmallmann/1065d49e06442ac0657c3cb5f12627ce to your computer and use it in GitHub Desktop.
digaOiLambda-languages
import json
import urllib.parse
def lambda_handler(event, context):
body = event['body']
print(body)
qs = urllib.parse.parse_qs(body)
print(qs)
language = ''
if ('text' in qs and len(qs['text']) > 0):
language = qs['text'][0]
language = language.lower()
response_text = 'Oi!'
if (language == 'ingles' or language == 'inglês'):
response_text = 'Hi!'
elif (language == 'espanhol'):
response_text = 'Hola!'
response = {
"response_type": "in_channel",
"text": response_text
}
return {
'statusCode': 200,
'body': json.dumps(response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment