How to Built a Slackbot with Dialogflow and FastAPI

Background

Back when we were actually in the office, our team efficiency was plagued with a recurring problem — we never knew where we wanted to eat. Team lunches became a difficult task to plan around, but as developers, we held both the great power and responsibility to automate trivial problems with new and popular technologies.

With our latest internal hackathon at NCR, we were given the opportunity to hack with Slack and create Slack apps with the help and advice from the Slack team. Our hackathon team came together to create a solution to this problem once and for all in our Slack workspace. With the use of Dialogflow, a platform that offers an interface for integrating natural language into apps, and FastAPI, a simple yet performant API framework for Python, we were easily able to create an interactive chatbot, named Eatware, that would do our bidding.

GIF demonstration of Eatware, our Slack bot

If you don’t know where to eat, try Eatware!

Here’s how we quickly set up our application using these three technologies.

Application Structure

We can split up our application structure into three layers:

  • Our presentation layer (Slack), where the user interacts with the bot and receives information from it
  • Our language processing layer (Dialogflow), which directly receives info from Slack
  • Our backend layer (Eatware API), receives webhook requests from Dialogflow, pulls restaurant information from external APIs, and sends the results back to Slack.

Diagram of application structure

Beginning with the presentation layer, we have the user prompt the bot to begin the experience. We identified the need for the user to converse with the bot in natural language to be a core part of the experience, so it blends in naturally with a team channel’s conversation (and it’s also a fun excuse to use the technology).

The user tags the bot and asks it in natural language that they’re looking for some food.

@Eatware, I’m looking for a bite to eat.

Dialogflow, the language-processing layer, is configured with Slack to read all the requests that mention the registered @Eatware application. It reads the sentence, uses the information we’ve trained it with to identify the user’s intent and any parameters they may have supplied. Dialogflow will respond in a conversation flow, prompting the user for any missing parameters, and when it’s reached a satisfactory point, it will make a webhook call to a location of our choosing. In our case, it’s an API we’ve set up to receive this call.

Our backend layer, built with FastAPI, receives the now-complete payload of parameters from the user and makes a call to an external service with our restaurant search terms. After this call is performed, our API maps the external response to a Slack payload, and sends the response to Slack in order to respond as the bot.

Now that we’ve covered how the application is set up, let’s get into the finer details of each part.

Dialogflow

Dialogflow is an E2E dev tool used to create conversational interfaces for websites and apps. Once the model is trained, it is compatible with multiple platforms including Facebook, LINE, Telegram, and more. For our particular project we integrated with Slack, where the user base composed of office workers enabled us to test features with potential users directly.

Dialogflow on Eatware is our middle layer, taking in user inputs flexibly from Slack, parsing relevant information out from a statement, then sending it as a webhook request to our API. When the API returns a response, Dialogflow takes the information, pieces it together into a user-friendly format, then outputs it back to the user as a Slack message.

Image for post

The main factor here is training our Dialogflow agent to recognize common sentence patterns that the user might use and determine keywords that fall into a category.

Initially, when presented with the sentence:

“Help me find an affordable Chinese restaurant nearby”

Dialogflow will not recognize these words as data. However, by manually training it by setting up a few words in the dictionary, such as “affordable = price” , “Chinese = food preference”, and “nearby = address”, the sentence will become strings of data to our agent.

Image for post

And thanks to its detection functionality, we don’t have to individually bind every word to a category; Dialogflow will attempt to do it itself when it finds a similar sentence structure. So next time when we ask the bot to “help me find an expensive Italian restaurant in Atlanta”, the agent detects the similarities in the sentence, deduces the user’s intent, and already correctly assumes the respective categories. As with all machine learning, Dialogflow improves its NLP prowess through everyday usage and user feedback.

Image for post

Once the parameters are identified, we can allow Dialogflow to passes these to a fulfillment webhook request to our API.

#chatbot #python #dialogflow #api #developer

What is GEEK

Buddha Community

How to Built a Slackbot with Dialogflow and FastAPI

How to Built a Slackbot with Dialogflow and FastAPI

Background

Back when we were actually in the office, our team efficiency was plagued with a recurring problem — we never knew where we wanted to eat. Team lunches became a difficult task to plan around, but as developers, we held both the great power and responsibility to automate trivial problems with new and popular technologies.

With our latest internal hackathon at NCR, we were given the opportunity to hack with Slack and create Slack apps with the help and advice from the Slack team. Our hackathon team came together to create a solution to this problem once and for all in our Slack workspace. With the use of Dialogflow, a platform that offers an interface for integrating natural language into apps, and FastAPI, a simple yet performant API framework for Python, we were easily able to create an interactive chatbot, named Eatware, that would do our bidding.

GIF demonstration of Eatware, our Slack bot

If you don’t know where to eat, try Eatware!

Here’s how we quickly set up our application using these three technologies.

Application Structure

We can split up our application structure into three layers:

  • Our presentation layer (Slack), where the user interacts with the bot and receives information from it
  • Our language processing layer (Dialogflow), which directly receives info from Slack
  • Our backend layer (Eatware API), receives webhook requests from Dialogflow, pulls restaurant information from external APIs, and sends the results back to Slack.

Diagram of application structure

Beginning with the presentation layer, we have the user prompt the bot to begin the experience. We identified the need for the user to converse with the bot in natural language to be a core part of the experience, so it blends in naturally with a team channel’s conversation (and it’s also a fun excuse to use the technology).

The user tags the bot and asks it in natural language that they’re looking for some food.

@Eatware, I’m looking for a bite to eat.

Dialogflow, the language-processing layer, is configured with Slack to read all the requests that mention the registered @Eatware application. It reads the sentence, uses the information we’ve trained it with to identify the user’s intent and any parameters they may have supplied. Dialogflow will respond in a conversation flow, prompting the user for any missing parameters, and when it’s reached a satisfactory point, it will make a webhook call to a location of our choosing. In our case, it’s an API we’ve set up to receive this call.

Our backend layer, built with FastAPI, receives the now-complete payload of parameters from the user and makes a call to an external service with our restaurant search terms. After this call is performed, our API maps the external response to a Slack payload, and sends the response to Slack in order to respond as the bot.

Now that we’ve covered how the application is set up, let’s get into the finer details of each part.

Dialogflow

Dialogflow is an E2E dev tool used to create conversational interfaces for websites and apps. Once the model is trained, it is compatible with multiple platforms including Facebook, LINE, Telegram, and more. For our particular project we integrated with Slack, where the user base composed of office workers enabled us to test features with potential users directly.

Dialogflow on Eatware is our middle layer, taking in user inputs flexibly from Slack, parsing relevant information out from a statement, then sending it as a webhook request to our API. When the API returns a response, Dialogflow takes the information, pieces it together into a user-friendly format, then outputs it back to the user as a Slack message.

Image for post

The main factor here is training our Dialogflow agent to recognize common sentence patterns that the user might use and determine keywords that fall into a category.

Initially, when presented with the sentence:

“Help me find an affordable Chinese restaurant nearby”

Dialogflow will not recognize these words as data. However, by manually training it by setting up a few words in the dictionary, such as “affordable = price” , “Chinese = food preference”, and “nearby = address”, the sentence will become strings of data to our agent.

Image for post

And thanks to its detection functionality, we don’t have to individually bind every word to a category; Dialogflow will attempt to do it itself when it finds a similar sentence structure. So next time when we ask the bot to “help me find an expensive Italian restaurant in Atlanta”, the agent detects the similarities in the sentence, deduces the user’s intent, and already correctly assumes the respective categories. As with all machine learning, Dialogflow improves its NLP prowess through everyday usage and user feedback.

Image for post

Once the parameters are identified, we can allow Dialogflow to passes these to a fulfillment webhook request to our API.

#chatbot #python #dialogflow #api #developer

What is a pre-built agent in Dialogflow CX?

Want to cut the design and deployment times for your chatbot? In this episode of Deconstructing Chatbots, we show how you can quickly create a virtual agent using Dialogflow CX’s pre-built agent template. We’ll cover how to change custom entities, build a custom flow, and customize this pre-built agent to fit your specific use case. Watch to learn how Dialogflow CX’s pre-built templates can help you easily and quickly build a virtual agent!

Timestamps:

  • 0:00 - Intro
  • 2:03 - Customizing the pre-built agent
  • 3:01 - Creating a route group
  • 4:13 - Testing your chatbot
  • 5:34 - Conclusion

#dialogflow #chatbot #developer

7 Best DialogFlow and Chatbots Courses to Learn in 2021

Hello guys, do you want to learn how to build chatbots? the darling child of Artificial Intelligence? If yes, then you have come to the right place. Earlier, I have shared the best courses to learn AI and in this course, I am going to share the best chatbots courses for beginners.

If you want to build chatbots but didn’t know where to start? I think joining an online course is a good idea, and if you are looking for some online courses, then you will find some good ones here, but before that, let’s talk about chatbots.

If you are not living under the rocks, you might have seen several applications of chatbots like in your online banking portal or any other websites.

Many companies like Apple, GoogleMicrosoft, and Amazon are investing millions in building their own AI-powered chatbots like Siri, Google Assistant, Cortena, and Amazon’s Alexa. They all are chatbots, primarily the voice-based chatbots.

Chatbots are nothing but Computer programs which use Artificial Intelligence to answer customers query. They have a huge database of problems and solutions, and they are continually learning and getting better and solving customer’s problems.

They are essential for any business as they not only allow them to provide 24x7 customer support but also it is very scalable. For example, if you have one customer executive for 1000 customers, then you will need 1000 executives for a million customers, but if you use chatbots, you can do all this with just one chatbot.

Based upon one online prediction, by 2021, 85% of customer interactions with the enterprise will be through automated means, which means chatbots and related technologies are going to rule the world.

Now that we are clear with the importance and benefits of chatbots let me tell you one more thing. If you are learning Data ScienceMachine Learning, and Artificial Intelligence, building a chatbot is a very engaging and practical activity.

It allows you to use different APIs like NLP in the real world, and that’s why I strongly suggest Machine learning enthusiasts develop at least one chatbot for the learning.

#artificial-intelligence #python #machine-learning #chatbots #dialogflow #7 best dialogflow and chatbots courses to learn in 2021

Nellie  Kemmer

Nellie Kemmer

1661020740

Simple URL Shortener Built using FastAPI, SQLAlchemy and ReactJS

URL Shortener with ReactJS, FastAPI

💻 Project Description

Simple URL shortener project built with ReactJS and FastAPI as a learing exercise.

✅ Demo

🚀 Powered By

Frontend

  • ReactJS
  • Material UI
  • React Query
  • React Tiny Link
  • React Copy To Clipboard

Backend

  • FastAPI
  • SqlAlchemy

📗 Installation (API & Web)

API backend:

$ cd backend
$ pip install -r requirements.txt
$ uvicorn src.main:app --reload

Web client:

$ cd client
2. $ npm install  # or yarn install
3. $ npm start    # or yarn start

📝 Author

Dr. Masroor Ehsan

.gitignore

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules/
.pnp
.pnp.js

# testing
coverage/

# production
build/

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*


__pycache__/
*.py[cod]
.venv/
shorty.db

.vscode/
.idea/

Author: masroore
Source code: https://github.com/masroore/reactjs-fastapi-url-shortener

#react #typescript #javascript #python #FastAPI

Erwin  Boyer

Erwin Boyer

1624608540

Google Dialogflow. Chatbot

  1. Login to google dialoflow using this link: https://dialogflow.cloud.google.com/
  2. Create a new Agent.

3.Lets create the same 3 intents which was created in lex(A bot for using medium app) and give sample responses in response section. But other wise you need to enable webhook for the intent in the Fulfillment section if the bot response is configured through backend adapter.

For links to be clickable and have database operations in bot or a good look and feel like carousals will need a nodejs channel adapter to be created.


#chatbots #chatbot-development #nlp #chatbots-for-business #google-dialogflow #google dialogflow