Slack Chatbots
com Python, AWS Lambda e Google Dialogflow
Mary Marchini


@mmarkini

Mary Marchini
Developers Team Leader @
Sthima
Node.js Collaborator
@mmarkini
http://mmarchini.me/
oss@mmarchini.me
https://github.com/mmarchini/

Node.js Diagnostics WG Member










Não configure na mão!
serverless




Pré-Requisitos
- Ter npm instalado
- Ter uma conta da AWS (gratúita)
- Ter uma conta do Slack (gratúita)
- Ter uma conta no Dialogflow (gratúita)
- Pode usar conta do Google
Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda




import json
def hello(event, context):
body = {
"message":
"Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response
handler.py
service: slack-chatbot
provider:
name: aws
runtime: python3.6
functions:
hello:
handler: handler.hello
serverless.yml
service: slack-chatbot
provider:
name: aws
runtime: python3.6
functions:
hello:
handler: handler.hello
events:
- http:
path: slack-chatbot/hello/
method: get
serverless.yml
Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda










Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda



Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda



























Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda











Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda



Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda
service: slack-chatbot
provider:
name: aws
runtime: python3.6
functions:
hello:
handler: handler.hello
events:
- http:
path: slack-chatbot/hello/
method: post
serverless.yml
import json
def hello(event, context):
data = json.loads(event['body'])
intent = data['queryResult']['action']
bot_name = data['queryResult']['parameters']['BotName']
fulfillment_text = "Sorry, I don't understand what you're saying"
if intent == "about":
fulfillment_text = f"I'm your friendly bot named {bot_name}!"
response = {
"statusCode": 200,
"body": json.dumps({
"fulfillmentText": fulfillment_text
})
}
return response
handler.py
handler.py

handler.py




Instalar Serverless e Criar projeto
Configurar Credenciais da AWS
Fazer deploy no AWS Lambda
Configurar integração Slack <-> Dialogflow
Criar Intenção no Dialogflow
Configurar Webhook no Dialogflow
Implementar resposta no AWS Lambda
@mmarkini
http://mmarchini.me/
oss@mmarchini.me
https://github.com/mmarchini/




www.sthima.com
Slack chatbots com Python, AWS Lambda e Google Dialogflow
By Mary Marchini
Slack chatbots com Python, AWS Lambda e Google Dialogflow
- 627